TypeScript
TypeScript — Is a programming language developed by Microsoft.
TypeScript — Is a typed superset of JavaScript, and includes its own compiler.
Type Definitions
- There are two main ways to get declarations for a library: Bundled and DefinitelyTyped.
- To be able to show errors and hints from other packages, the compiler relies on declaration files. A declaration file provides all the type information about a library. This enables us to use javascript libraries like those on npm in our project.
- Bundled - The library bundles its own declaration file. To check if a library has bundled types, look for an index.d.ts file in the project. Some libraries will have it specified in their package.json under the typings or types field.
- DefinitelyTyped is a huge repository of declarations for libraries that don’t bundle a declaration file. To get declaration file from DefinitelyTyped run: 'yarn add --dev @types/react' or 'npm i --save-dev @types/react'.
Related concepts
→
TypeScript
→
- TypeScript with React: Adding TypeScript to a Project
- TypeScript with React: Configuring the TypeScript Compiler
- TypeScript with React: File extensions in TypeScript
- TypeScript with React: Running TypeScript
- TypeScript with React: Using TypeScript with Create React App
- TypeScript with React
- TypeScript: Type Definitions