jsconfig.json
descendant
of tsconfig.json
widthallowJs:true
项目根目录 添加该配置文件
Why do I need a jsconfig.json file
Benefits
- Better IntelliSense
- Explicit Project
Tip: To check if a JavaScript file is part of JavaScript project, just open the file in VS Code and run the
JavaScript: Go to Project >Configuration
command. This command opens the jsconfig.json that references the JavaScript file. A notification is shown if the file is > not part of any jsconfig.json project.
Using webpack aliases
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"ClientApp/*": ["./ClientApp/*"]
}
}
}
Global variables and type checking
Create a globals.d.ts
interface Window {
webkitNotifications: any;
}
declare var CAN_NOTIFY: number;
jsconfig.json
{
"compilerOptions": {
"baseUrl": "./", // root directory
"checkJs": true, // 开启js type 检查
"paths": {
// path alias
"app": ["./app"]
},
"module": "commonjs",
"target": "es2020",
"jsx": "preserve",
"strictFunctionTypes": true
},
// 配置 lib types 推导文件
"typeAcquisition": {
"include": ["jquery"]
},
// 项目文件
"exclude": ["node_modules", "**/node_modules/*", "dist", "build", "tmp"]
}