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?
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"
]
}
For anyone running into this problem try replacing this:
const { ConnectionPool } = require("mssql");
With this:
import { ConnectionPool } from "mssql"
... for your equivalent library. This solved my issue.
Of course don't forget that you need both the implementation and the @type modules:
npm i mssql
npm i -D @types/mssql
Intellisense for node_modules folder not work in versions <= 2.0.3 (current).
It will be available in version 2.0.5 ( https://github.com/Microsoft/TypeScript/issues/9323 )
To temporarily fix you can use the night build: npm install -g typescript@next
It worked for me.
This is not a problem with typescript.
In visual code 1.9 onwards they have security issues.It try to read some data from your windows drive and if you do not have rights then it do not show intellisense.
If you do not have full admin rights on your system then uninstall 1.9.x version and install VSCodeSetup-1.8.1
this works for me.
For me it was the parameter hints which wouldn't show. Intellisense worked but when I opened a function bracket I couldn't see any hints for the parameters.
I tried all the version management suggestions above but it didn't fix it.
Finally I found a setting in VSCodes settings.json
under the "[typescript]"
key called editor.parameterHints.enabled
.
For some reason unknown this was not enabled...why, god why.
Setting it to true now gives me the parameter hints.
Yay.
I would update the tsconfig.json to be relative paths:
{
"compilerOptions": {
"out": "test.js"
},
"files": [
"./test2.ts",
"./tester.ts"
]
}
Also as metioned by steve don't mix modules (although that wouldn't case an error here). And also, perhaps don't use out : https://github.com/TypeStrong/atom-typescript/blob/master/docs/out.md
Check the setting typescript.suggest.autoimports
and make sure it's set to true
.
I've had the same issue, disabled all my extensions but it still wasn't working. I checked the insider version, and it was working on the same project - which for me, meant two things:
tsconfig.json
setting, as the insider build is using the same config files.I checked my user settings file (Clicking on the icon to show you the JSON version of the modified settings), and saw the file was polluted with settings added in there by extensions I haven't used in a while. I started organizing this file and going through the settings, and I eventually found this:
typescript.suggest.autoimports
was set to false. I changed that to true, and voila - it started working.
I have no idea what changed this to false (I have an idea that it might be an extension I used, Typescript Importer , but I can't be sure.
Lots of good answers here, but for anyone who's reading this now and has been on my level for the past hour:
have you tried restarting VSC?
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.