Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (20 sloc) 584 Bytes

TypeScript

Add custom types for external libraries

Set typeRoots in tsconfig.json

"typeRoots": [                           
  "src/types", // Custom types goes here
  "node_modules/@types" // Fallback to default @types path
]

Create new type file with subdirectory name as the packages name eg. for wordcut package : src/types/wordcut/index.d.ts

declare module 'wordcut';

You can add more types to functions / variables later within {}

declare module 'wordcut' {
  function init(): void;
  function cut(s: string): string;
}
You can’t perform that action at this time.