Fut*_*ake 2 typescript visual-studio-code auto-import
我有一个项目,我正在添加一些打字稿,但打字稿不会自动导入。我不明白为什么。请参阅下面我的文件结构、tsconfig 和示例:
配置文件
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"pretty": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noImplicitAny": true,
"noImplicitReturns": false,
"noImplicitUseStrict": false,
"outDir": "../Js/",
"baseUrl": "./",
},
"include":[
"*.ts"
],
"compileOnSave": true
}
Run Code Online (Sandbox Code Playgroud)
应用 ts 预期导入建议
在这里,我期待看到ImageRowsInitializer从名为images-row.ts.
图像行.ts
export class ImageRowsInitializer {
private image_rows : ImagesRow[];
constructor() {
const htmlImageRows = document.getElementsByClassName("row-container");
for (let i = 0; i < htmlImageRows.length; i++) {
const imagerow = htmlImageRows[i];
this.image_rows.push(new ImagesRow(imagerow as HTMLElement));
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我没有得到建议..
如果需要更多信息,请告诉我,我很乐意提供:)
现在从命令部分,选择工作区打字稿版本。
如果错误仍未修复,则 - 转到设置,搜索“tsdk”,单击 settings.json 中的编辑并删除该属性 "typescript.tsdk": "node_modules\\typescript\\lib"
第三个选项是包含“Typescript”文件夹下的所有文件。在您的情况下,打字稿无法找到您项目中的所有文件。要找到所有文件,请将includetsconfig 中的数组修改为"include":[ "**/*" ]. 它会通知 VSCode 的 TS 编译器搜索“Typescript”文件夹下的所有 ts 文件。
这可能会解决您的自动导入问题。
| 归档时间: |
|
| 查看次数: |
2492 次 |
| 最近记录: |