Common TypeScript Gotchas
This might be the most difficult process in TypeScript. If the module doesn't already contain type definitions, someone probably wrote them in the DefinitelyTyped
repository (the types for my-module
might be available if you npm install @types/my-module
).
If you still run into errors with importing afterwards (or if a DefinitelyTyped
module doesn't exist), add the following line to your index.d.ts
:
declare module "my-other-module";
If necessary, restart the hot reloading process (ctrl-c
and then npm start
again).
Instead of using import myModule from "my-module
, try import * as myModule from "my-module"
.
If you get a TypeScript compilation error after adding a new file and you have no idea why, restarting the hot reloading process usually works.
Found a problem or got a suggestion? Please open a GitHub issue and tag it with documentation
!