SolvedDefinitelyTyped TS2430 when using @types/request with typescript 2.4.0

when using typescript 2.4.0 i get this error

ERROR in [at-loader] ./node_modules/@types/request/index.d.ts:66:15 
    TS2430: Interface 'DefaultUriUrlRequestApi<TRequest, TOptions, TUriUrlOptions>' incorrectly extends interface 'RequestAPI<TRequest, TOptions, TUriUrlOptions>'.
  Types of property 'defaults' are incompatible.
    Type '(options: TOptions) => DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>' is not assignable to type '{ (options: TOptions): RequestAPI<TRequest, TOptions, RequiredUriUrl>; (options: (UriOptions & TO...'.
      Type 'DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>' is not assignable to type 'RequestAPI<TRequest, TOptions, RequiredUriUrl>'.
        Types of property 'delete' are incompatible.
          Type '{ (uri: string, options?: TOptions, callback?: request.RequestCallback): TRequest; (uri: string, ...' is not assignable to type '{ (uri: string, options?: TOptions, callback?: request.RequestCallback): TRequest; (uri: string, ...'. Two different types with this name exist, but they are unrelated.
            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'.
15 Answers

✔️Accepted Answer

This error disappeared after changing "@types/request" from 0.0.43 to ^0.0.45, "typescript" from 2.3.2 to ^2.4.1 and "@types/node" from 7.0.31 to ^7.0.33.

Other Answers:

the same for me. Only solution today: npm r -D @types/request

Seeing the same issue. It would seem that the fix is to simply add | Url to the OptionalUriUrl interface in the relevant file.

interface OptionalUriUrl {
    uri?: string | Url;
    url?: string | Url;
}

This at least fixes it on my machine. I'm not sure if these typings are entirely correct, but it would seem that way. It seems as if baseUrl is given, uri || url must be strings. However, that doesn't get checked now anyway -- and the whole Required/OptionalUrl typings are for if you've set a default URL using requests.defaults.

My mistake: I don't see this on 2.3.4, but on 2.4.0

When I upgraded the dependency to "@types/request": "^0.0.45", the error disappeared. Previously the upper limit was 0.0.42. tsc version that I am using is 2.4.1.

This is breaking nearly ALL my projects because I use request and it's @types a lot!

More Issues: