打字稿自动导入不工作macos
typescript auto imports not working macos
我有一个项目,我正在添加一些打字稿,但打字稿不会自动导入。我不明白为什么。请参阅下面我的文件结构、tsconfig 和示例:
ts 配置
{
"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
}
文件结构
App ts 预计导入建议
在这里,我希望看到从名为 images-row.ts
.
的文件中导入 ImageRowsInitializer
的建议
图片-row.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));
}
}
}
我不明白为什么我没有收到建议..
如果需要更多信息,请告诉我,我很乐意提供 :)
点击VSCode右下角的TypeScript版本。
现在从命令部分,select 工作区打字稿版本。
如果错误仍未修复,则-
前往设置,
搜索“tsdk”
单击 settings.json 中的编辑
并删除 属性 "typescript.tsdk": "node_modules\typescript\lib"
第三个选项是包含“Typescript”文件夹下的所有文件。
在您的情况下,打字稿无法找到您项目中的所有文件。
要找到所有文件,请将 tsconfig 中的 include
数组修改为 "include":[ "**/*" ]
。它会通知 VSCode 的 TS 编译器搜索“Typescript”文件夹下的所有 ts 文件。
这可能会解决您的自动导入问题。
我有一个项目,我正在添加一些打字稿,但打字稿不会自动导入。我不明白为什么。请参阅下面我的文件结构、tsconfig 和示例:
ts 配置
{
"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
}
文件结构
App ts 预计导入建议
images-row.ts
.
ImageRowsInitializer
的建议
图片-row.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));
}
}
}
我不明白为什么我没有收到建议..
如果需要更多信息,请告诉我,我很乐意提供 :)
点击VSCode右下角的TypeScript版本。
现在从命令部分,select 工作区打字稿版本。
如果错误仍未修复,则-
前往设置,
搜索“tsdk”
单击 settings.json 中的编辑
并删除 属性 "typescript.tsdk": "node_modules\typescript\lib"
第三个选项是包含“Typescript”文件夹下的所有文件。
在您的情况下,打字稿无法找到您项目中的所有文件。
要找到所有文件,请将 tsconfig 中的 include
数组修改为 "include":[ "**/*" ]
。它会通知 VSCode 的 TS 编译器搜索“Typescript”文件夹下的所有 ts 文件。
这可能会解决您的自动导入问题。