小编Ale*_* Le的帖子

将 NextJS 迁移到 TypeScript:“strict”:true 不起作用

我正在将现有的 NextJS 项目迁移到 TypeScript,大多数事情似乎都运行良好。我 npm 安装了建议的类型文件,NextJStsconfig.json为我生成了一个默认文件,我能够将我的文件转换为 .tsx 文件,并且我看到正常的 TypeScript 行为,例如智能感知和悬停查看详细信息。

但是,我将“严格”false翻转为true,并且根本没有收到任何错误。例如,隐式“anys”根本不加下划线。

这是默认的 tsconfig,其中“strict”属性被翻转。

{
    "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"]
}

Run Code Online (Sandbox Code Playgroud)

typescript next.js

7
推荐指数
0
解决办法
814
查看次数

标签 统计

next.js ×1

typescript ×1