I have a project and I am adding some typescript but typescript doesnt auto import. And i dont understand why. See below my file structure, tsconfig and an example:
ts config
{
"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 expected import suggestion
Here I am expecting to see a suggestion for an import for ImageRowsInitializer
from the file called images-row.ts
.
images-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));
}
}
}
I dont get why i am not getting suggestions..
please let me know if more information is needed i am happy to supply :)
Click on TypeScript version in the lower-right corner of VSCode.
Now from the command section, select workspace typescript version.
if the error is still not fixed, then -
go to settings,
Search for "tsdk"
click on edit in settings.json
and delete the property "typescript.tsdk": "node_modules\\typescript\\lib"
The Third Option is to include all the files under your "Typescript" folder.
In your case, typescript is unable to locate all the files in your project.
To locate all the files, modify your include
array in tsconfig to "include":[ "**/*" ]
. It will inform the TS compiler of VSCode to search all the ts files under "Typescript" folder.
This may fix your auto import issue.