TypeScript: Typescript auto-complete not working in VSCode
I’m trying to make use of Puppeteer within a ts file which works fine except the VSCode Intellisense stops working a soon as I’m inside a .ts and not a .js file. I’ve seen some posts about this incident but none could help me. What I did:
- created a project via npm init
- installed dependencies as follows:
"dependencies": {
"@types/node": "^14.0.14",
"events": "^3.1.0",
"puppeteer": "^4.0.1",
"typescript": "^3.9.5" }
"devDependencies": {
"puppeteer-tsd": "0.0.2" }
- created tsconfig.json
"target": "es5",
"lib": ["es2015", "dom"],
"outDir": "./dist",
.
.
.
"include": ["src/**/*", "node_modules/puppeteer-tsd/src/index.d.ts"]
- created src and dist folder
- put a main.ts inside my src
- told VSCode to use the project TS version instead of its own
Then I compiled. Everything works fine. But I get no IntelliSense to help me out while I type. So I created a .js file in my src directory, copied the code from my main.ts inside it and then I got Intellisense to work perfectly fine with all suggestions and so on. And I have no idea left what I could try except accepting it and code without it. I’d be greatful for any suggestions on what could be the issue. Thx in advance!
Meanwhile I found out, that it works fine with non imported functions like console.log(). It’s only Puppeteer (or probably any imported module).
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (4 by maintainers)
I did a quick test. Angular 10 moved to a “solution-style tsconfig.json” - https://angular.io/guide/migration-solution-style-tsconfig.
In the tsconfig.app.json, a standard Angular 10 app has:
Once I changed the include like to be:
The quick fix now works, as well as the auto-import of the file:
So this must be a result of this change to the tsconfig files in Angular 10.
Off to open an issue there…
The issue here seems to be that
tsconfig.app.json
does not include new file into the configured project as it explicitly lists files that should be and till you import new file it wont be part of the configured project. The issue is with configuration file and how it is structured. Is new file suppose to go to tsconfig.app.json or tsconfig.spec.json or something else is not clear to derive either so there isnt much we can do.