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
Typescript &引用;任何;javascript单元测试中未识别关键字_Typescript_Jasmine_Karma Jasmine_Jasmine Jquery - Fatal编程技术网

Typescript &引用;任何;javascript单元测试中未识别关键字

Typescript &引用;任何;javascript单元测试中未识别关键字,typescript,jasmine,karma-jasmine,jasmine-jquery,Typescript,Jasmine,Karma Jasmine,Jasmine Jquery,无法识别“any”关键字。错误表示符号“any”位于无法访问的模块中。你能帮帮我吗 您编写代码的方式意味着您将变量x指定给一个对象。我猜您想要声明一个具有结构的变量,您可以这样做: let x= { y: { z: any } }; 请注意x变量后的冒号(:) 更清楚地说: let x: { y: { z: any } }; [] // let variable : structure = value; // The following code is OK

无法识别“any”关键字。错误表示符号“any”位于无法访问的模块中。你能帮帮我吗

您编写代码的方式意味着您将变量
x
指定给一个对象。我猜您想要声明一个具有结构的变量,您可以这样做:

let x= {
  y: {
    z: any
  }
};
请注意
x
变量后的冒号(

更清楚地说:

let x: {
  y: {
    z: any
  }
};
[]

// let variable : structure = value;

// The following code is OK
let x: {
  y: {
    z: any
  }
} = { 
  y: {
      z: "test"
  }
};

// The following code throws an error:

let x: {
  y: {
    z: any
  }
} = { 
  y: {
      z: "test"
  },
  notDefined : {}
};