我使用的是一个混合了类型脚本和Java脚本文件的项目,因为我们刚刚采用了类型脚本.这个项目过go 只有Java脚本文件,但通过使用jsconfig.json
个文件,我仍然能够获得智能感知(例如.我可以在按住CTRL
键的同时单击导入文件以直接转到导入的文件).
然而,自从采用了TypeScrip(并混合了多种文件)后,VS Code就不再为Java脚本文件提供智能感知功能了.它在TypeScrip中工作得很好,我知道这是一个事实,它是导致问题的文件扩展名,因为如果我将foo.js
重命名为foo.tsx
,智能感知就会重新开始工作.
我仍然有一个jsconfig.json
文件,还有我的tsconfig.json
文件,但显然这不足以使VS代码将智能感知恢复到JS文件.有谁能解释一下我是怎么做到的吗?
下面是我的tsconfig.json
:
{
"ts-node": {
"require": ["tsconfig-paths/register"]
},
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"checkJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"paths": {
"app/*": ["./app/*"],
"pages/*": ["./pages/*"],
"src/*": ["./src/*"]
},
"plugins": [{ "name": "next" }],
"strictNullChecks": true,
"target": "es2015"
},
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}