post-me icon indicating copy to clipboard operation
post-me copied to clipboard

Add TypeScript support for "Import post-me as a script"

Open ChrisTorng opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe. I'm using "Import post-me as a script" way, on TypeScript. But can't find a built in way to code strong type in TypeScript.

Describe the solution you'd like I add a new export_post-me.d.ts as:

export * from '../lib/post-me/dist/index';
export as namespace PostMe;

Then I can new PostMe.WindowMessenger() object, or get PostMe.RemoteHandle type. I suggest post-me to include export as namespace PostMe, and add description in README.md. Let new comer like me spent less time try to find the right way.

Describe alternatives you've considered I have no other way to make post-me strong type, except any. If you have a better way to make TypeScript happy, I'm glad to know. And still hope to add description in README.md too.

Additional context No.

ChrisTorng avatar Sep 01 '21 08:09 ChrisTorng

Hey thanks for opening the issue!

I'm not familiar with consuming the library as a script in a TypeScript context, so I don't quite understand the instructions above.

Can you give me some more step by step instructions?

Once I understand how to fix/document the issue, I'll be happy to make the necessary changes to post-me to cover this use case

alesgenova avatar Sep 01 '21 12:09 alesgenova

I added https://github.com/ChrisTorng/PostMeTypeScript to show the problem and the fix of mine.

ChrisTorng avatar Sep 02 '21 02:09 ChrisTorng

Sorry I fix the link of previous post to https://github.com/ChrisTorng/PostMeTypeScript.

ChrisTorng avatar Sep 06 '21 00:09 ChrisTorng

Thanks for the example, I'll open a PR to update the docs

alesgenova avatar Sep 07 '21 12:09 alesgenova