【问题标题】:Typescript compiler cannot find Jquery type definitions even though they are already installedTypescript 编译器无法找到 Jquery 类型定义,即使它们已经安装
【发布时间】:2021-04-15 04:54:26
【问题描述】:

我正在尝试运行tsc 来编译我所有的打字稿文件。它曾抱怨无法为 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

然后我安装了它告诉我安装的 jquery 类型定义 (yarn add @types/jquery --dev)。我尝试再次运行编译器,它仍然抱怨说它找不到名称$,尽管事实上已经安装了 jquery 类型

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

【问题讨论】:

    标签: jquery typescript typescript-typings yarnpkg


    【解决方案1】:

    您需要将 /node_modules/@types 添加到您的 tsconfig typeRoots: ["./src/typings", "/node_modules/@types"],因为您正在覆盖它

    【讨论】:

      猜你喜欢
      • 2011-09-23
      • 2012-05-16
      • 2021-08-18
      • 2020-10-31
      • 1970-01-01
      • 2014-05-14
      • 2019-05-09
      • 2022-11-13
      • 2019-07-20
      相关资源
      最近更新 更多