You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何关闭TSC运行时生成的提示信息?

如何关闭TypeScript编译器(tsc)的提示信息,只保留错误和警告

你遇到的JSDoc types may be moved to TypeScript types这类提示属于TypeScript的建议性诊断信息,默认会被tsc输出,但可以通过两种方式关闭,只保留错误和警告:

方法一:命令行参数直接控制

运行tsc时添加--noSuggestionDiagnostics参数,即可屏蔽所有提示类信息:

tsc --noSuggestionDiagnostics

方法二:在tsconfig.json中永久配置

在compilerOptions里新增"noSuggestionDiagnostics": true,后续每次运行tsc都会自动生效:
修改后的tsconfig.json示例:

{
    "extends": "@tsconfig/svelte/tsconfig.json",
    "include": ["src/**/*.d.ts", "src/**/*.ts","src/**/.svelte", "src/vite-env.d.ts"],
    "exclude": ["node_modules/*", "public/*"],
    "compilerOptions": {
        "baseUrl": ".",
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "importHelpers": true,
        "lib": ["dom", "ESNext"],
        "module": "ESNext",
        "moduleResolution": "node",
        "noUnusedLocals": false,
        "importsNotUsedAsValues": "preserve",
        "skipLibCheck": true,
        "strict": true,
        "target": "ESNext",
        "noSuggestionDiagnostics": true // 新增该行关闭提示信息
    }
}

这类提示不属于错误或警告级别,是TypeScript提供的优化建议,noSuggestionDiagnostics就是专门用来控制是否显示这类信息的配置项,在文档中属于偏细节的设置,容易被忽略。

内容的提问来源于stack exchange,提问作者JustBarnt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 13:21:15