Typescript 错误TS2339:属性';增加小时数';不存在于类型';日期';

Typescript 错误TS2339:属性';增加小时数';不存在于类型';日期';,typescript,typescript-typings,spfx,Typescript,Typescript Typings,Spfx,lib.es5.d.ts文件的第729行有: interface Date { addHours: (h: any) => any; /** Returns a string representation of a date. The format of the string depends on the locale. */ 那么,为什么会有这样一句话: const newdatetime = myDateValue.addHours( -1 ); 错误TS2339:类

lib.es5.d.ts文件的第729行有:

interface Date {
 addHours: (h: any) => any;
    /** Returns a string representation of a date. The format of the string depends on the locale. */
那么,为什么会有这样一句话:

const newdatetime =   myDateValue.addHours( -1 );
错误TS2339:类型“Date”上不存在属性“addHours”? 有没有其他方法可以在typescript中添加小时数? 现在我做到了:

 debugger;
  const myDateValue = new Date();
  const newdatetime =   myDateValue.addHours( -1 );
  console.log(newdatetime);
而大口大口的发球有一个错误: 错误-[tsc]src/webparts/ecgTsxDpcKendo/components/EcgTsxDpcRequestForm.tsx(44,37):错误TS2339:类型“Date”上不存在属性“addHours”。
我应该说这是在一个SPFx工作台中,我从来没有听说过
addHours()
方法。你应该使用

很简单:

const myDateValue=new Date();
myDateValue.setHours(myDateValue.getHours()-1);

console.log(myDateValue)显示更多代码,您的代码中似乎有一些输入错误。