Typescript

Typescript files

Lim Yee Han
Jan 16, 2023

Implementation files — .ts

  • Contain types and executable code

Declaration files — .d.ts

  • contain only type information
  • lib.[something].d.ts are declaration files for built-in types

DefinitelyTyped/@types

Centralised repo storing declaration files. Definitions on DefinitelyTyped are automatically published to npm under the @types scope.

@types in dependencies vs devDependencies

If you use the type in implementation files, import with devDependencies

If you use the type in declaration files, import with dependencies

--

--