Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
668 views
in Technique[技术] by (71.8m points)

javascript - Visual Studio Code Intellisense Typescript not working

I've been trying for ages but I cannot seem to get Visual Studio Code intellisense working beyond a single file for typescript no matter what I do. This is on windows as well as Ubuntu.

I've included a tsconfig.json file but it still doesn't have any intellisense on a project scale.

My current test project contains the following:

tsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "out": "test.js"
    },
    "files": [
        "test2.ts",
        "tester.ts"
    ]
}

tasks.json:

{
    "version": "0.1.0",
    "command": "tsc",
    "showOutput": "always",
    "windows": {
        "command": "tsc.exe"
    },
    "args": ["-p", "."],    
    "problemMatcher": "$tsc"
}

test2.ts:

module test
{
    export class test2
    {

    }
}

tester.ts:

module test
{
    export class tester
    {
        public testy: test2;
    }
}

In the class tester test2 isn't picked up by intellisense, even if i change it to test.test2. Adding variables to test2 doesn't help either.

Does anyone know any possible causes as to why it isn't working at all?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In my case, I had to select the work space version over VSCode version of typescript.

Click on the version number in the blue ribbon at the bottom

enter image description here

And select work space version in the options appearing in the top bar

enter image description here

Hope that helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...