Jquery Typescript自定义d.ts文件
我有一个项目,我正在转换为Typescript。我已经下载了最新的@types,正在尝试创建一个自定义的.d.ts文件。到目前为止,该文件如下所示:Jquery Typescript自定义d.ts文件,jquery,typescript,types,Jquery,Typescript,Types,我有一个项目,我正在转换为Typescript。我已经下载了最新的@types,正在尝试创建一个自定义的.d.ts文件。到目前为止,该文件如下所示: /// <reference path="../../../node_modules/@types/jquery/index.d.ts"/> interface jQuery{ iCheck(): JQuery; bootstrapSwitch(): JQuery; } interface jQueryStatic{
/// <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;
//
接口jQuery{
iCheck():JQuery;
bootstrapSwitch():JQuery;
}
接口jQueryStatic{
notific8():JQuery;
}
声明var notific8:JQueryStatic;
声明var-isCheck:JQuery;
声明var bootstrapSwitch:JQuery;
在我试图使用中的定义的文件中,我使用
/// <reference path="../utility/custom.d.ts" />
//
Visual studio识别出路径是正确的,但当我将鼠标悬停在实现路径的代码上时,我得到:
[ts] Property 'notific8' does not exist on type 'JQueryStatic<HTMLElement>'
[ts]类型“JQueryStatic”上不存在属性“notific8”
及
[ts]属性“iCheck”在类型“JQuery”上不存在。
[ts]属性“bootstrapSwitch”在类型“JQuery”上不存在。
我试着将声明行移动到应用程序文件中,但仍然出现相同的错误?有人知道为什么Typescript不能识别它吗?我正在使用typescript 2.5.2和“@types/jquery”:“^3.2.12”谢谢。问题可能是,因为您的变量类型是
jquery
,而不是jquery
这同样适用于
JQueryStatic
(Typescript应该是JQueryStatic
,以便识别notific8
属性)问题可能是,因为您的变量类型是JQuery
,而不是JQuery
这同样适用于JQueryStatic
(对于要识别notific8
属性的Typescript,应该是JQueryStatic
)
[ts] Property 'iCheck' does not exist on type 'JQuery<HTMLElement>'.
[ts] Property 'bootstrapSwitch' does not exist on type 'JQuery<HTMLElement>'.