更新时间:2022-05-27 22:05:45
不需要导入。而是在文件顶部添加对Typescript定义文件的引用。所以 WebAPI.js
的第一行应该是
An import is not required. Instead, add a reference to the Typescript definition file the top of the file. So the first line of the WebAPI.js
should be
/// <reference path ="../typings/jquery/jquery.d.ts"/>
而不是
import { $ } from '../jquery-3.1.1';
根据 DefinitelyTyped wiki:
TypeScript声明文件是定义类型的函数,函数
和外部第三方JavaScript库中的参数。通过在TypeScript代码中使用
a声明文件,将启用Intellisense
并对您正在使用的外部库进行类型检查。
A TypeScript declaration file is way of defining the types, functions and parameters in an external third-party JavaScript library. By using a declaration file in your TypeScript code will enable Intellisense and type checking against the external library you are using.
jquery.d.ts
是 DefinitelyTyped的一部分图书馆在GitHub上找到。绝对可以通过NuGet包管理器在Visual Studio项目中包含Typed。
jquery.d.ts
is a part of the DefinitelyTyped Library found on GitHub. Definitely Typed can be include in Visual Studio projects via the NuGet Package Manager.