首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编辑VSCode文件时出现.tsx错误

编辑VSCode文件时出现.tsx错误
EN

Stack Overflow用户
提问于 2022-08-16 10:48:12
回答 1查看 57关注 0票数 0

在用.tsx编辑VSCode文件时,我一直存在错误。这些错误只影响编辑器,代码编译良好,编译器不会抱怨任何事情。

如何删除这些错误和警告?

这是我的tsconfig.json

代码语言:javascript
复制
{
    "compilerOptions": {
        "lib": ["dom", "dom.iterable", "esnext"],
        "module": "esnext",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "strict": true,
        "alwaysStrict": true,
        "strictNullChecks": true,
        "noUncheckedIndexedAccess": true,

        "noImplicitAny": true,
        "noImplicitReturns": true,
        "noImplicitThis": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "allowUnreachableCode": false,
        "noFallthroughCasesInSwitch": true,

        "target": "es5",
        "outDir": "out",
        "declaration": true,
        "sourceMap": true,

        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "allowJs": false,
        "skipLibCheck": true,
        "forceConsistentCasingInFileNames": true,

        "jsx": "preserve",
        "noEmit": true,
        "isolatedModules": true,
        "incremental": true,

        "baseUrl": ".",
        "paths": {
            "@/*": ["./src/*"],
            "@/public/*": ["./public/*"]
        }
    },
    "exclude": ["./out/**/*", "./node_modules/**/*", "**/*.cy.ts"],
    "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
EN

回答 1

Stack Overflow用户

发布于 2022-08-16 17:58:14

另一个(首选)选项是解决问题:)

错误告诉您检测到不可访问的代码,因此使代码可访问,或者删除它/临时注释它,因为它没有做任何事情。

代码语言:javascript
复制
const add = (a: number, b: number) => {
  return a + b;
  // code never gets here since a value is already returned from the function
  const otherValue = a + 5; // unreachable code detected
}
代码语言:javascript
复制
const add = (a: number, b: number) => {
  throw new Error("Something went wrong");
  return a + b; // same here
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73372774

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档