chatengine-io / react-chat-engine

React component for a cheap and easy chat API
137 stars 35 forks source link

Add type declaration for react-chat-engine #19

Open danBamikiya opened 3 years ago

danBamikiya commented 3 years ago

Hi, I'm using typescript with react-chat-engine so typescript requires me to have a type declaration module. Could you include that or tell me how to create one. Typescript version: 4.2.3 image image

GRTO commented 3 years ago

Hi, I'm using typescript with react-chat-engine so typescript requires me to have a type declaration module. Could you include that or tell me how to create one. Typescript version: 4.2.3 image image

I think they haven't added a type definition for the library yet.

alamorre commented 3 years ago

We can work on this in the future but we're currently not focusing on TS support. Normal JS/React will support it.

GRTO commented 3 years ago

For those how are having issues with running the library with TS, you can create a react-chat-engine.d.ts file and then inside this file add the following line code declare module "react-chat-engine"; If you create your project using create-react-app TS is not going to complain about it, if not, in your tsconfig.json inside include array, add as a string the name of your newd.ts file. As @alamorre said, it is going to be supported in the future. Then, you are going to have your library with no error type. The solution we have so far for react TS. :)

alamorre commented 3 years ago

Hey so I'm happy to work on this now! Any of you know where I should start? Can I make some top level declaration in the src/ folder to make it TS compatible?

alamorre commented 3 years ago

Are there any docs/resources I should check out to make the project TS compatible?

danBamikiya commented 3 years ago

Well usually you'll want users to install types for your package seperately as npm i -D @types/react-chat-engine because it isn't written in typescript. To type your project that way visit Definitely Typed where most packages not created with typescript publish the types definition for their packages to.

Creating a react-chat-engine.d.ts means just declaring types for what you're exporting from your package. View react type definitions files as an example of how your react-chat-engine.d.ts file should be. ✌️

alamorre commented 3 years ago

Thank you very much!

I'll give this a try, but I'll also put a bounty on this task for 50 USDC !!

If somebody can mod the Package to make this typescript supported by default, they can comment their USDC address on the PR and I'll wire it once approved.

If not I'll get to it in the next few weeks.

danBamikiya commented 3 years ago

😄 I would have sent a PR but I'm currently on a road trip (without my laptop) and would be back home an Friday night. But I'll see what I can accomplish with GitHub Mobile.

alamorre commented 3 years ago

Haha no rush! If you do it this weekend I'll get ya USDC right after - thanks a bunch this will be fun!

dawncast commented 11 months ago

hey, were there any updates for this? the props are giving an error for me in TS: "Property 'height' does not exist on type 'IntrinsicAttributes'."

Jane49-cloud commented 5 months ago

Still no support for ts?

Swag-blips commented 2 weeks ago

Damn, still no typescript support