I just ran an update in NuGet to update my my packages. Afterwards, I can no longer compile and I receive the above error.
The jquery definition file is in my project. But for some reason, the bootstrap definition file can no longer find it.
It's been a while since I worked on this project. I'm pretty sure I had my definition files in a completely different directory before the update. But most of the code and file structure has been created automatically by Visual Studio NuGet packages.
Where are these links or references located so that the definition files can be found properly? I'm very new to TypeScript, so if you can explain in detail or provide links for further reading, it would be appreciated
Edit:
I've discovered that these are called Triple-Slash Directives. But that pages doesn't tell me enough to understand this error.
It tells me that <reference types="..."/>
should be used for @types
packages which is what I believe .d.ts
files are. I tried changing the name of jquery.d.ts
to index.d.ts
. And I've tried including the whole path such as ../jquery/jquery.d.ts
. Neither of these worked.
Finally, I found the following line in angular.d.ts
:
/// <reference path="../jquery/jquery.d.ts" />
I copied that into the bootstrap index.d.ts
and that seemed to fix the error.
But this doesn't make sense to me. First, I'm trying to link to a definition file, not a TypeScript file. So I should be using reference types
, not reference path
, according to the above article. But reference types
does not work. What am I missing here?
The article also says:
Use these directives only when you’re authoring a d.ts file by hand.
I didn't write these files. They came from NuGet and look to be automatically generated. So why do I need to change this?
They came from NuGet and look to be automatically generated.
Don't use nuget for type definitions. NPM is the way to go.
npm install @types/jquery -D
And then you can:
<reference types="jquery"/>
welcome to the future 🌹