为什么打字稿总是给我在配置文件中找不到输入错误?

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

为什么打字稿总是给我

No inputs were found in config file
错误?

当我在 VS Code 中使用

tsconfig.json
时,但当我尝试构建它时,它给了我错误。

终端:

error TS18003: No inputs were found in config file '/Users/user/Desktop/projects/ts/.vscode/tsconfig.json'. 
Specified 'include' paths were '["/Users/user/Desktop/projects/ts/mathweb/app.ts"]' and 'exclude' paths were '["/Users/user/Desktop/projects/ts/mathweb/app.ts"]'.


Found 1 error.

The terminal process "zsh '-c', 'tsc -p /Users/user/Desktop/projects/ts/.vscode/tsconfig.json'" failed to launch (exit code: 2).

Terminal will be reused by tasks, press any key to close it.

我搜索了SO,一些答案告诉我创建一个空文件,所以我这样做了:

但这不起作用。其他答案告诉我在 tsconfig.json 中使用 rootDir,我这样做了,但也不起作用。

这让我很困惑。我不熟悉打字稿,我只想 ts 编译到指定的目录,这就是现在发生的事情。

我使用的是vscode ide,我不确定这是IDE的问题,还是我的错

tsconfig.json:

{
"compilerOptions": {

    "outDir": "/Users/user/Desktop/projects/ts/mathweb/app.ts",
    "rootDir": "./mathweb"

},

"include": [
    "/Users/user/Desktop/projects/ts/mathweb/app.ts"
]
,

"exclude": [
    "/Users/user/Desktop/projects/ts/mathweb/app.ts"
]

}

javascript json typescript visual-studio-code tsconfig
2个回答
2
投票

include 需要相对路径,因此您在排除中添加了 app.ts

{
"compilerOptions": {

    "outDir": ".",
    "rootDir": "."

},

"include": [
    "./app.ts"
]

}


编辑:因为根目录上没有 tsconfig 试试这个

{
    "compilerOptions": {
    
        "outDir": "../dist",
        "rootDir": "."

    },

    "include": [
        "./../mathweb/"
    ]
}


-1
投票

对我来说,我只需关闭“VS Code 编辑器”并重新打开它,它就可以工作并且错误已经消失了!!!

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