Skip to content

Type definition file

  • Adaptor between ts code and js libraries
  • Some libraries include automatically. E.g. axios, express
  • To install: @types/{library-name}. E.g. @types/faker
  • Ctrl+Click on the library brings to the type definition file (index.d.ts)

Global variable in the project

  • Need also a type definition file
  • E.g. google maps script on HTML
  • Install: @types/googlemaps
  • Typing 'google' now shows the available methods

Type definition files

  • @types/node
  • @types/googlemaps
  • @types/faker
  • @types/express
  • @types/cookie-session
  • @types/mongoose
  • @types/cookie-session
  • axios (built in)
  • HTML (built in into Node.js). E.g. HTMLElement
  • ts-express-decorators (decorator for express)