В моих проектах CRA TypeScript, когда у меня есть ошибка TS в моем коде, TS предотвращает компиляцию сервера разработки и вместо этого отображает ошибку в браузере и консоли. Мне нравится такое поведение.
В моем новом проекте Gatsby этого не происходит. IDE сообщает мне об ошибке, но gatsby develop
запускает код независимо, как и с обычным js. Как я могу настроить его так, чтобы он вел себя так, как я привык от CRA?
Я использую gatsby-plugin-typescript
. Это мой gatsby-config.js:
module.exports = {
siteMetadata: {
title: `Gatsby Default Starter`,
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
author: `@gatsbyjs`,
},
plugins: [
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/assets`,
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `gatsby-starter-default`,
start_url: `/`,
},
},
{
resolve: `gatsby-plugin-typescript`,
options: {
isTSX: true, // defaults to false
allExtensions: true, // defaults to false
},
},
`gatsby-plugin-emotion`,
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
],
}
это мой tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"downlevelIteration": true,
"jsx": "react"
},
"include": [
"src/**/*"
]
}