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?
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
And select work space version in the options appearing in the top bar
Hope that helps.
It's because you have told the compiler you are using external modules:
"module": "commonjs",
But you are actually trying to use internal modules:
module test
It is best to choose one way or the other.
If you are using external modules - use:
test2.ts
export class test2 {
}
tester.ts
import ModuleAlias = require('test2');
export class tester {
public testy: ModuleAlias.test2;
}
If you aren't using external modules, you can use your original code, but remove the "module": "commonjs"
flag.
{
"compilerOptions": {
"out": "test.js"
},
"files": [
"test2.ts",
"tester.ts"
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With