Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Typescript自定义d.ts文件_Jquery_Typescript_Types - Fatal编程技术网

Jquery Typescript自定义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{

我有一个项目,我正在转换为Typescript。我已经下载了最新的@types,正在尝试创建一个自定义的.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;
//
接口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>'.