'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!
Edit: Meanwhile I found out, that it works fine with non imported functions like console.log(). It's only Puppeteer (or probably any imported module).
Edit 2: Heres a Link to my Log File.
Solution 1:[1]
Apart from VSCode's TypeScript language features provided by the extension vscode.typescript-language-features
that needs to be functional, your imports must be correct for built-in or packaged (@types/x
) type declarations of modules to be considered.
import/require
:
import x = require('x');
Gives you type awareness but is valid only in TypeScript.
const/require
:
const x = require('x');
Also valid In TypeScript but does not give you type awareness; x
will be of type any
.
For more information on module imports, see this question.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | alexanderdavide |