$ npm install gatsby-plugin-typescript
Provides drop-in support for TypeScript and TSX.
yarn add gatsby-plugin-typescript typescript
gatsby-config.js
file.tsconfig.json
file on your root directory.gatsby-config.js
plugins: [`gatsby-plugin-typescript`];
Or with optional configuration:
plugins: [
{
resolve: "gatsby-plugin-typescript",
options: {
transpileOnly: true, // default
compilerOptions: {
target: `esnext`,
experimentalDecorators: true,
jsx: `react`,
}, // default
},
},
];
tsconfig.json
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "esnext",
"jsx": "react",
"lib": ["dom", "es2015", "es2017"]
},
"include": ["./src/**/*"]
}
© 2010 - cnpmjs.org x YWFE | Home | YWFE