Configure Typescript for Jquery
By default, jquery will not be recognized in typescript files you create. This means that any jquery code you use will show up as erroneous and you can't make use of the auto-complete functionality. However, this is easy enough to remedy as shown below.
Copy the typescript declaration file into your project from here. Unfortunately the download links do not appear to work so you have to manually copy/paste.
Place the content into a file called
jquery.d.ts in your project.
Add a relative path link to that file at the very top of your typescript files that require jquery. For example:
/// <reference path="../../jquery.d.ts" />
If the link for the jquery.d.ts doesn't work, I grabbed a copy at the time of writing this article so you can grab it with the command below.
- Stack Overflow - How do I get jQuery autocompletion in TypeScript?
- Stack Overflow - Where can I get the latest typescript JQuery definition file from?
First published: 16th August 2018