【发布时间】:2021-08-18 02:36:33
【问题描述】:
我想在我的项目中在 typescript 旁边使用 nextjs。 我使用了 npx create-next-app --typescript(将 typescript 添加到下一个的官方方式)。 一切正常,但是当出现打字稿错误时,例如 const st:string =3;编译器成功运行,我只在我的 IDE 中收到错误,编译器不会停止。我想在运行时 npm run dev 命令编译器向我显示错误然后失败。 如果有人可以帮助我,我将不胜感激
这是我的 tsconfig 文件
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
【问题讨论】:
-
它是intended,在开发过程中默认是不可能的。但是,在运行
next build时会进行类型检查。
标签: javascript reactjs typescript next.js tsconfig