3

I need 'react-keydown' module in my project but i cant find typing's for it . How can I use this module in my typescript project?

1
  • I got answer that I should use "--allowJs" flag. But i don't understand how to correctly include library if i compile with this flag. Commented May 17, 2016 at 12:08

2 Answers 2

1

Typescript need to recognize your JS library as a Typescript. To achieve this you need a ".d.ts" file (react-keydown.d.ts), It's a interface for the JS functions. There's a Github called DefinitelyTyped and they have React there. I don't know if you only want one function or if this can help but here's the link.

DefinitelyTyped/react

npm Reference

Sign up to request clarification or add additional context in comments.

2 Comments

That link throws 404
It seems they changed the repository structure. I already updated the link and added a reference to npm.
1

Joao mentioned DefinitelyTyped which is where you should start. If you can't find the library there you either need to create your own definition or declare the 3rd party library as any. You won't get any typedefs of course but you will be able to compile and use the library.

declare var ThirdPartyLibrary;
ThirdPartyLibrary.doStuff();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.