我暂时不使用TypeScript.只有ES6和巴贝尔.
我没有在node_modules中安装TypeScript .
每次打开工作区时,我都会收到来自VSCode的特定警告.
\node_modules\typescript\lib没有指向有效的tsserver安装.回归捆绑的TypeScript版本.
我怎样才能摆脱这种警告?或者我应该改变编辑器以便感到平静?
我有一个使用TypeScript的简单示例项目:https://github.com/unindented/ts-webpack-example
运行tsc -p .(tsc版本1.8.10)会引发以下情况:
app/index.ts(1,21): error TS2307: Cannot find module 'components/counter'.
components/button/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'.
components/button/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'.
components/counter/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'.
components/counter/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'.
components/counter/index.ts(4,27): error TS2307: Cannot find module 'shared/backbone_with_subviews'.
components/counter/index.ts(5,20): error TS2307: Cannot find module 'components/button'.
Run Code Online (Sandbox Code Playgroud)
它抱怨所有本地文件的导入,如下所示:
import Counter from 'components/counter';
Run Code Online (Sandbox Code Playgroud)
如果我将它改为相对路径它可以工作,但我不想,因为它使我的生活更加困难时移动文件:
import Counter from '../components/counter';
Run Code Online (Sandbox Code Playgroud)
该vscode代码库不使用相对路径,但一切工作正常他们,所以我必须失去在我的项目的东西:https://github.com/Microsoft/vscode/blob/0e81224179fbb8f6fda18ca7362d8500a263cfef/src/vs/languages/typescript/common /typescript.ts#L7-L14
你可以看看我的GitHub仓库,但万一它有帮助这里是tsconfig.json我正在使用的文件:
{
"compilerOptions": …Run Code Online (Sandbox Code Playgroud) 我有一个如下的项目结构:
\n.\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 my-app/\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .configs/\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 webpack.merge.ts\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 webpack.dev.config.ts\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 webpack.prod.config.ts\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 node_modules\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src/\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 index.tsx\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 package.json\nRun Code Online (Sandbox Code Playgroud)\n在命令行上运行 TypeScripttsc --project .configs/tsconfig.json编译不会出现问题。但 VSCode IDE 在.tsx. 我不想禁用 TS 警告,因此这对我不起作用:How to disable TypeScript warnings in VSCode? ,当模块存在时,为什么 VS Code 会抛出“找不到模块 'typescript'.ts(2307)”?
VSCode 中是否有一个设置,我设置了一个路径,以便 VSCode IDE TypeScript 可以用于当前项目。我知道如果我将 放在tsconfig.json根目录 ( my-app) 中,VSCode IDE 将按预期工作。但我想将所有配置脚本保存在一个文件夹中而不是根目录中。VSCode 允许这样做吗?
typescript tsconfig visual-studio-code vscode-extensions tsconfig-paths