编译.ts文件时出现打字稿错误TS2430

时间:2019-12-04 16:02:59

标签: javascript typescript

使用Typescript网站(https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html)上指定的以下命令

npm install -g typescript

使用以下行创建文件greeter.ts

function greeter(person) {
return "Hello, " + person;
}

let user =“简用户”;

document.body.textContent = greeter(用户);

tsc greeter.ts命令创建greeter.js,但还会报告以下错误

../../../../node_modules/@types/request/index.d.ts:66:15 - error TS2430: Interface 
'DefaultUriUrlRequestApi<TRequest, TOptions, TUriUrlOptions>' incorrectly extends interface 
'RequestAPI<TRequest, TOptions, TUriUrlOptions>'.
 The types of 'defaults(...).delete' are incompatible between these types.
Type '{ (uri: string, options?: TOptions, callback?: RequestCallback): TRequest; (uri: 
string, callback?: RequestCallback): TRequest; (options: OptionalUriUrl & TOptions, 
callback?: RequestCallback): TRequest; }' is not assignable to type '{ (uri: string, 
options?: TOptions, callback?: RequestCallback): TRequest; (uri: string, callback?: 
RequestCallback): TRequest; (options: (UriOptions & TOptions) | (UrlOptions & TOptions), 
callback?: RequestCallback): TRequest; }'.
  Types of parameters 'options' and 'options' are incompatible.
    Type '(UriOptions & TOptions) | (UrlOptions & TOptions)' is not assignable to type 
'OptionalUriUrl & TOptions'.
      Type 'UriOptions & TOptions' is not assignable to type 'OptionalUriUrl & TOptions'.
        Type 'UriOptions & TOptions' is not assignable to type 'OptionalUriUrl'.
          Types of property 'uri' are incompatible.
            Type 'string | Url' is not assignable to type 'string'.
              Type 'Url' is not assignable to type 'string'.

 interface DefaultUriUrlRequestApi<TRequest extends Request,

我使用的版本如下: MacOS版本:10.15.1(19B88); 节点:v13.0.1; tsc:版本3.7.3

需要什么配置才能消除此错误?

0 个答案:

没有答案