Hello React and TypeScript
  • Introduction
  • Hello World Sample Code
    • Setting Up Samples
    • Component Basics
    • Components in Separate Files
    • Component Props and State
    • Component Interactivity
    • Accept User Input
    • Component Composition
    • Define Props and State Types
    • Form Input Types
  • Development Environment
    • IDE
    • Package Management
    • TypeScript Environment
    • Testing
    • Automation
  • React
  • TypeScript
  • TypeScript and React
  • References
  • Glossary
Powered by GitBook
On this page
  • TypeScript Definition Files
  • TypeScript Configuration

Was this helpful?

  1. Development Environment

TypeScript Environment

PreviousPackage ManagementNextTesting

Last updated 5 years ago

Was this helpful?

TypeScript Definition Files

To get ready for TypeScript development we need typings for React. An easy way to pull in typings is with tsd, a package manager to search and install TypeScript definition files.

npm install -g tsd

You can install TypeScript typings with tsd. When you install your typings are saved in tsd.json. You can create a tsd.json file by running

tsd init

To install a typing, for example react, you can run tsd

tsd install react --save

You can find a lot of TypeScript definition at .

To make it easier, in the source code there is a tsd.json that includes all of the typings necessary for the demo application. To install these typing just run

tsd install

This will get the typings and place them in the typings folder. In the typings folder there is a tsd.d.ts file that has all of the typing references bundled into one file.

TypeScript Configuration

There are a lot of configurations that you can set for the TypeScript compiler. To help manage the settings you can create a tsconfig.json file to hold the configuration.

We take advantage of this file in the Gulp task to compile TypeScript. Actually, in our gulpfile we use the tsconfig in tsc.createProject('tsconfig.json') to create a project that we can use in our compile task.

https://github.com/DefinitelyTyped/DefinitelyTyped