typescript
  • A crash guide to Typescript
  • Intro
    • What Typescript IS for?
    • What Typescript is NOT for?
    • Setting up tsconfig.json
  • Types are spooky! (How types work?)
  • Handling mutable code
  • The primitive types
  • Interfaces or Type Aliases? Oh, my!
  • The `class`, a creature which spans both realms
  • Structural typing
  • Control Flow Analysis
  • More advanced type syntaxes for another day
  • Generics
  • Modules
  • 3rd-party types
  • Epilogue
Powered by GitBook
On this page

Was this helpful?

3rd-party types

One can usually obtain types from 3rd party libraries through the following means:

  • The library itself publishes .d.ts definitions along with the package, referencing it on the typings key of package.json;

  • Someone publishes types for the library at the DefinitelyTyped repository, available through npm @types/<lib>;

  • There are methods for manually declaring a 3rd party library's types inside the consumer project;

What if the library does not have types?

  • The library will be imported as any but you can continue to use it as-is;

  • If noImplicitAnyis turned on, a declare "library" entry must be declared in a global file;

3rd party typescript types are also used to power JS type completion in VS Code.

PreviousModulesNextEpilogue

Last updated 3 years ago

Was this helpful?