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
Javascript 类型为“JQuery”的值上不存在TypeScript错误TS 2094/2095属性“x”_Javascript_Typescript - Fatal编程技术网

Javascript 类型为“JQuery”的值上不存在TypeScript错误TS 2094/2095属性“x”

Javascript 类型为“JQuery”的值上不存在TypeScript错误TS 2094/2095属性“x”,javascript,typescript,Javascript,Typescript,嘿,我一直在想这个问题,但似乎真的很奇怪。我知道应该在顶部包含.d.ts文件。我最近将ts从0.831升级到了0.95。做了所有必要的更改,但仍然出现错误 更具体地说,我正在使用JQGrid,在明确类型的repo中没有类型化文件,所以我创建了一个。这是定义文件 /// <reference path="..\Imports\jquery-1.8.d.ts" /> interface JQuery { jqGrid(options?: JQGrid.JQGrid_Op

嘿,我一直在想这个问题,但似乎真的很奇怪。我知道应该在顶部包含.d.ts文件。我最近将ts从0.831升级到了0.95。做了所有必要的更改,但仍然出现错误

更具体地说,我正在使用JQGrid,在明确类型的repo中没有类型化文件,所以我创建了一个。这是定义文件

    /// <reference path="..\Imports\jquery-1.8.d.ts" />

interface JQuery {
    jqGrid(options?: JQGrid.JQGrid_Options): JQuery;
    fluidGrid(options: JQGrid.FluidGrid_Options): JQuery;
}

declare module JQGrid {
    export interface JQGrid_ColModel {
        ...
    }

    export interface JQGrid_Options {
        ...
    }

    interface FluidGrid_Options {
        ...
    }
}
错误TS2095:未能从代码中找到符号“JQGrid”

private gridOptions: JQGrid.JQGrid_Options;
完整的代码是

/// <reference path="..\..\Scripts\Base\ViewModelBase.ts" />
/// <reference path="..\..\Scripts\Imports\JQGrid.d.ts" />
module Biz.Views {
    export class ProspectsTab extends ViewModelBase{
        private gridOptions: JQGrid.JQGrid_Options;   <--error TS2095
        private _businessId: number;
        private _isInitialized: boolean = false;

        constructor () {
            this.gridOptions = {};
            $("#prospectsByReferrer").jqGrid(this.gridOptions);  <---error TS2094
        }
我不明白的是为什么TS在上面声明的时候看不到这个类型。我做得不对的是什么?我已经没有包括打字在内的想法了。谢谢你抽出时间


顺便说一句,我用的是Visual Studio 2012,intellisense没有给我一个红色的曲线。只有我的控制台输出错误

我想这是一个愚蠢的答案,但它总是发生在我身上。。我也在使用VS和typescript


你忘了在HTML文档中包含JQGrid.js文件了吗?

当我的TS文件中有特殊字符时,TS编译器似乎崩溃了。我对Word中的代码进行了注释,Word中有一些奇怪的字符,它们自己格式化,例如…,-,等等。删除这些“奇怪”字符可以再次编译

您需要在出现错误的行号上共享代码。
/// <reference path="..\..\Scripts\Base\ViewModelBase.ts" />
/// <reference path="..\..\Scripts\Imports\JQGrid.d.ts" />
module Biz.Views {
    export class ProspectsTab extends ViewModelBase{
        private gridOptions: JQGrid.JQGrid_Options;   <--error TS2095
        private _businessId: number;
        private _isInitialized: boolean = false;

        constructor () {
            this.gridOptions = {};
            $("#prospectsByReferrer").jqGrid(this.gridOptions);  <---error TS2094
        }