如果文件未打开,Vscode 不会显示打字稿错误

Tay*_*har 4 typescript visual-studio-code

我在本机反应上使用打字稿。当我的某个文件中有错误时,vscode 不会在“问题”选项卡中显示它,除非我打开了该文件。

打开文件之前: 文件未打开

打开文件后: 文件已打开

tsconfig.json:

{
  "extends": "@tsconfig/react-native/tsconfig.json"
}
Run Code Online (Sandbox Code Playgroud)

@tsconfig/react-native/tsconfig.json:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "React Native",
  "_version": "2.0.3",
  "compilerOptions": {
    "target": "esnext",
    "module": "commonjs",
    "types": ["react-native", "jest"],
    "lib": [
      "es2019"
    ],
    "allowJs": true,
    "jsx": "react-native",
    "noEmit": true,
    "isolatedModules": true,
    "strict": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  },
  "exclude": [
    "node_modules",
    "babel.config.js",
    "metro.config.js",
    "jest.config.js"
  ]
}
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能使所有错误都显示在问题选项卡中并且侧栏中的文件具有红色下划线?

brc*_*-dd 7

  1. Cmd+ Shift+ P
  2. 搜索“打开用户设置(json) ”并打开settings.json文件。
  3. 在那里添加这一行:
    "typescript.tsserver.experimental.enableProjectDiagnostics": true,
    
    Run Code Online (Sandbox Code Playgroud)

这仍然是一个实验性功能。您可以在 GitHub 上跟踪此功能请求以获取更新。