简体   繁体   中英

VSCode Typescript Intellisense not working in the most simple project setup

I have been using VSCode intellisense happily since quite a long time.

Now I am doing something very simple: create a new project, add a package like rxJs and then start coding.

What I find is that intellisense is not working as it is used to.

In particular, if I just open a file like test.ts and add the following innocent code

of('abc'). // of is a function of rxJs

I get this response from intellisense

智能感知没有给予正确的支持

At the same time if I start importing manually the function and do ctrl+space between the brackets I get the expected help.

这是智能工作

I am pretty sure I am missing something very basic, but after few hours of browsing I could not find any answer.

Here my tsconfig.json

{
    "compilerOptions": {
      "target": "es6",
      "module": "commonjs",
      "outDir": "dist",
      "sourceMap": true,
      "declaration": true,
      "noUnusedLocals": true,  
      "noUnusedParameters": true  
    },
    "include": [
      "src/*.ts",
      "src/**/*.ts"
    ],
    "exclude": [
      "node_modules"
    ],
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ]
  }

The function of needs to be imported for it to be available in the file.

Error:

of('abc'). // of is a function of rxJs

No error:

import {of} from 'rxjs';
of('abc'). // of is a function of rxJs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM