如何应用特定的“编译”仅到特定文件? (tsconfig.json)

发布于 2025-02-13 11:25:31 字数 304 浏览 0 评论 0原文

是否只能将特定的TSCONFIG选项应用于1个文件?

以下是我的tsconfig.json,

{
  ...
  "compilerOptions": {
    ...
    "keyofStringsOnly": false,
    "resolveJsonModule": true,
    "esModuleInterop": true
  },
  ...
}

我想仅在指定组件文件中使用选项“ resolvejsonmodule”和“ esmoduleop”。

有什么办法吗?谢谢。

Is it possible that apply specific tsconfig options to 1 file only?

Below is my tsconfig.json

{
  ...
  "compilerOptions": {
    ...
    "keyofStringsOnly": false,
    "resolveJsonModule": true,
    "esModuleInterop": true
  },
  ...
}

I would like to use option "resolveJsonModule" and "esModuleInterop" in specify component file only.

Is there any way for this? thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥有 2025-02-20 11:25:31

是的,您必须在目录内创建一个新的tsconfig.ts文件,在您的特别内容文件中。您可以使用扩展,如果您可以重复使用原始选项,也可以修改其上的一些选项:

示例:

{
    "extends": "../../tsconfig.json",
    "compilerOptions": {
        "strictPropertyInitialization": false
    }
}

注意:也许您需要重新启动代码编辑器以再次读取Typescript条件。

Yes, you must create a new tsconfig.ts file inside the directory where is your especial file. You can use extends if you can reuse original options, or you can modify some options on it:

Example:

{
    "extends": "../../tsconfig.json",
    "compilerOptions": {
        "strictPropertyInitialization": false
    }
}

NOTE: Maybe you need to restart your code editor to force read again typescript conditions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文