Search code examples
jquerytypescripttypescript-typingsyarnpkg

Typescript compiler cannot find Jquery type definitions even though they are already installed


I'm trying to run tsc to compile all my typescript files. It had complained about not being able to find name $ for Jquery.

src/public/js/main.ts:68:15 - error TS2581: Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery

I then installed the jquery type definitions that it had told me to install (yarn add @types/jquery --dev). I tried running the compiler again and it still complained saying it cannot find name $ despite the fact jquery types are already installed

package.json https://hastebin.com/segaxiyuyo.json
tsconfig.json https://hastebin.com/culonoluno.json


Solution

  • you need to add /node_modules/@types to your tsconfig typeRoots: ["./src/typings", "/node_modules/@types"] since you are overriding it