Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
714 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...