How To Use Typescript Definitions To Get Intellisense For My Own Javascript Services In Vs Code?
Solution 1:
I can reproduce the behavior described if I create a tsconfig.json
file without the "allowJs": "true"
compiler option. If you want your TypeScript and JavaScript files to be considered as a single project, you should have a tsconfig.json
file with "allowJs": "true"
and no jsconfig.json
file.
Solution 2:
You don't need to add a reference to typings/index.d.ts
. The easiest would be to just add your declarations to a global declaration file, anywhere in your project.
Further, instead of using var
and namespace
, just use interface
.
Eg. in the root of your directory, you can easily add
// index.d.tsinterfaceFoo {
bar: () =>void
}
interfaceBaz { some: number }
Solution 3:
I had the same issue and discovered that the editor (VSCode) was looking in the wrong directory for the file, problem was solved by relative referencing the correct path, the specific path will vary, but in my example it was:
///<reference path="../../typings/index.d.ts" />
index.d.ts contains the following:
/// <reference path="globals/core-js/index.d.ts" />
/// <reference path="globals/jasmine/index.d.ts" />
/// <reference path="globals/node/index.d.ts" />
and my directory/file structure appears as follows:
Post a Comment for "How To Use Typescript Definitions To Get Intellisense For My Own Javascript Services In Vs Code?"