$ npm install gatsby-plugin-typescript
Provides drop-in support for TypeScript and TSX.
npm install gatsby-plugin-typescript
gatsby-config.js
file.gatsby-config.js
plugins: [`gatsby-plugin-typescript`]
This plugin uses babel-plugin-transform-typescript
to transpile typescript. It does not do type checking. Also since the TypeScript
compiler is not involved, the following applies:
Does not support namespaces. Workaround: Move to using file exports, or migrate to using the module { } syntax instead.
Does not support const enums because those require type information to compile. Workaround: Remove the const, which makes it available at runtime.
Does not support export = and import =, because those cannot be compile to ES.next. Workaround: Convert to using export default and export const, and import x, {y} from "z".
https://new.babeljs.io/docs/en/next/babel-plugin-transform-typescript.html
First of all you should set up your IDE so that type errors are surfaced. Visual Studio Code is very good in this regard.
In addition, you can see the instructions in TypeScript-Babel-Starter
for setting up a type-check
task.
© 2010 - cnpmjs.org x YWFE | Home | YWFE