I am currently working on a TypeScript project where I have set "declaration": true in tsconfig.json to generate a d.ts file. The generated d.ts file looks like this:
/// <reference types="jquery" />
declare class KatApp implements IKatApp {
selector: string;
private static applications;
static remove(item: KatApp): void;
static get(key: string | number | Element): KatApp | undefined;
// removed rest for brevity
I attempted to follow the instructions outlined in IntelliSense based on TypeScript declaration files to enable IntelliSense in a non-TypeScript project (specifically a web forms project).
On one of my pages, I have the following code snippet:
<script>
(function () {
/**
* @type {KatApp}
*/
var application = KatApp.get('{id}');
// According to the documentation, I should be getting IntelliSense
// suggestions for 'application.' at this point.
})();
</script>
<p>Hello World</p>
Visual Studio is raising an error stating that it cannot find the 'jquery' reference. I am trying to determine the best approach to resolve this issue considering:
- This project does not utilize npm/bower dependencies at all, and I prefer to avoid them if possible.
- I checked the %LOCALAPPDATA%\Microsoft\TypeScript folder as mentioned in the article and found jQuery there.
- What if the KatApp.d.ts file has other interfaces that were necessary for compiling the TypeScript project but are now required because those types are not included inside KatApp.d.ts?
Update:
Following the suggestion by @EliasSchablowski, I used npm to install typings for jquery. In the screenshot below, you can see the types under the node_modules\@types folder along with my two *.d.ts files. I no longer encounter compile issues with jquery, but IntelliSense is still not functioning:
https://i.sstatic.net/I0Iqp.png
The next screenshot demonstrates IntelliSense working, but only when my KatApp.d.ts file is open in the editor:
https://i.sstatic.net/KCNN3.png
Is this the expected behavior?