【发布时间】:2018-03-04 10:36:27
【问题描述】:
我有一个项目要转换为 Typescript。我已经下载了最新的@types 并试图创建一个 custom.d.ts 文件。到目前为止,该文件看起来像这样:
/// <reference path="../../../node_modules/@types/jquery/index.d.ts"/>
interface jQuery{
iCheck(): JQuery;
bootstrapSwitch(): JQuery;
}
interface jQueryStatic{
notific8(): JQuery;
}
declare var notific8: JQueryStatic;
declare var isCheck: JQuery;
declare var bootstrapSwitch: JQuery;
在我试图使用定义的文件中,我使用它来引用它
/// <reference path="../utility/custom.d.ts" />
Visual Studio 识别出路径是正确的,但是当我将鼠标悬停在实现它的代码上时,我得到:
[ts] Property 'notific8' does not exist on type 'JQueryStatic<HTMLElement>'
和
[ts] Property 'iCheck' does not exist on type 'JQuery<HTMLElement>'.
[ts] Property 'bootstrapSwitch' does not exist on type 'JQuery<HTMLElement>'.
我尝试将声明行移动到应用程序文件中,但我仍然遇到同样的错误?有人知道为什么 Typescript 无法识别它吗?我正在使用 typescript 2.5.2 和 "@types/jquery": "^3.2.12" 谢谢。
【问题讨论】:
标签: jquery typescript types