question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript imports with Penpal 5.2.0

See original GitHub issue

Using Penpal 5.1.1, I was importing types and defining variables in a TypeScript project as follows:

import {AsyncMethodReturns, Connection, TCallSender, connectToParent} from 'penpal';

protected parentConnection: Connection<TCallSender>;
protected parent: AsyncMethodReturns<TCallSender>;

this.parentConnection = connectToParent({...});
this.parent = await this.parentConnection.promise;

Unfortunately, using Penpal 5.2.0, I cannot find the equivalent.

It seems TCallSender was replaced by CallSender and most types need to be imported from the lib folder:

import {AsyncMethodReturns, CallSender} from 'penpal/lib/types';

My main issue is about Connection which seems not exported. How to import it?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
marlon-tuckercommented, Aug 6, 2020

That has been something I’ve been meaning to submit a PR for actually.

Both the return types for connectToParent and connectToChild are not exported, which meant we couldn’t store the result as a strongly typed class member (we needed to keep track of it so we could dispose it properly in the future).

I hacked around that by defining a interface with a destroy function.

I just noticed you also seem to be importing TCallSender? That’s a generic type argument for the connectToParent function, so that should have never been importable.

But to answer your question we don’t import Connection currently, but we would if we could.

0reactions
Aaroniuscommented, Aug 12, 2020

@marlon-tucker, a PR for Connection would be great! I’m going to close out this issue and create a new one for Connection.

Read more comments on GitHub >

github_iconTop Results From Across the Web

penpal-es5 - npm
Penpal is a promise-based library for securely communicating with iframes via postMessage. The parent window can call methods exposed by iframes, pass arguments ......
Read more >
penpal/package-lock.json at master - GitHub
A promise-based library for securely communicating with iframes via postMessage. - penpal/package-lock.json at master · Aaronius/penpal.
Read more >
penpal: Versions - Openbase
Full version history for penpal including change logs. ... TypeScript types could previously (and still can) be imported through a child path as...
Read more >
Importing images in TypeScript React - "Cannot find module"
I am trying to import images to use inside a React component with TypeScript. The bundler I'm using is Parcel (not Webpack).
Read more >
Compare Versions | @teambit/changelog | npm
@babel/plugin-syntax-import-assertions 7.20.0 ... @teambit/typescript.modules.ts-config-mutator 0.0.76. remove. @teambit/ui 0.0.451 ... ansi-styles 5.2.0.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found