2

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.

m1212e
  • 303
  • 4
  • 8
  • Does this answer your question? [Visual Studio Code Intellisense Typescript not working](https://stackoverflow.com/questions/30394831/visual-studio-code-intellisense-typescript-not-working) – ABGR Jun 29 '20 at 14:17
  • If you go to the Output panel and select TypeScript in the dropdown, what does it show? – H.B. Jun 29 '20 at 14:30
  • @ ABGR Saw that one already, but thanks. – m1212e Jun 29 '20 at 16:02
  • @H.B. Here you go: [Info - 14:25:00.908] Using tsserver from: *myparentfolderpath*\node_modules\typescript\lib [Info - 14:25:00.912] Forking... [Info - 14:25:00.926] Starting... [Info - 14:25:00.928] Forking... [Info - 14:25:00.939] Starting... – m1212e Jun 29 '20 at 16:03
  • Just close your project(means VSCode) and open it again and check.. – Rohit Tagadiya Jun 29 '20 at 16:07
  • @ Rohit Tagadiya Unfortunately the old "Have you turned it off and on again..?" didn't do the job this time :( – m1212e Jun 29 '20 at 16:19

1 Answers1

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.

alexanderdavide
  • 1,487
  • 3
  • 14
  • 22