IntelliJ IDEA 和 ts-node 未检测到继承的 tsconfig.json 覆盖的文件

问题描述 投票:0回答:1

首先,看起来这个问题很复杂。除了 IntelliJ IDEA 和 ts-node 之外,可能是 TypeScript 和 tsx 的问题(看起来 this topic 相关)。目前我不确定bug在哪一边,所以我根据实际看到的情况决定了标题,但看起来只是冰山一角。无论如何,我想,我们不能把所有事情都视为单一问题。

目标 TypeScript 文件

此问题对于

Tests/Automated
下面的所有文件都存在(显然,不仅如此),但我将以
Tests/Automated/Sample.test.ts
文件为例。

主要 tsconfig.json

此配置文件不涵盖

Tests/Automated/Sample.test.ts
:

{

  "compilerOptions": {

    "target": "ES2022",
    "moduleResolution": "Node",
    "esModuleInterop": true,

    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "skipLibCheck": true,

    "removeComments": true,

    "outDir": "Distributable/",
    "declaration": true
  },

  "include": [ "Source/**/*" ]

}

tsconfig.test.json - 测试文件的配置

此文件预计涵盖

Tests/Automated/Sample.test.ts

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext"
  },
  "include": [ "Tests/**/*" ]
}

问题

IntelliJ IDEA 抱怨

module
target
选项错误:

enter image description here

TS1378:仅当模块选项设置为 es2022、esnext、system、node16、nodenext 或preserve,并且目标选项设置为 es2017 或更高版本时,才允许使用顶级等待表达式。

如果尝试运行也会出现同样的错误

ts-node Tests/Automated/Sample.test.ts -p CoreLibrary/Package/tsconfig.test.json
typescript ts-node
1个回答
0
投票

使用完整路径,例如:

import {things} from "folder/file.ts"

things()

使用

ts-node-esm

添加到

tsconfig.json
"allowImportingTsExtensions": true,

© www.soinside.com 2019 - 2024. All rights reserved.