Definitelytyped: TS2430 when using @types/request with typescript 2.4.0

Created on 14 Jun 2017  路  13Comments  路  Source: DefinitelyTyped/DefinitelyTyped

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'.

Most helpful comment

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.

All 13 comments

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

The same for me as well, I am using 2.3.4 TS version to keep it working.

+1

I'm using

{
"@types/node": "7.0.32",
"typescript": "^2.3.2",
"request": "2.60.0"
}

and removed a lot of unnecessary dependencies that were using types/node: 7.0.33 to resolve this issue.

[Edit]
Referencing:

17147

It seems that the fix has not been released yet.

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 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.

@pedrogryzinsky doesn't work with "@types/request" 0.0.45, "@types/node" ^8.0.7 and "typescript" ^2.4.1.

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

This has been fixed, this issue can be closed. Just update your dependencies!

This is still happening to me. I don't know why I'm not being able to update the types to 0.0.45... I got Node at 8.1.2, npm at 5.0.3, TypeScript at 2.4.2 and request at 2.81.0. Any thoughts?

@ggabriel96 If you have not already, you could try removing your yarn.lock and, if you have it, your package-lock.json, do yarn cache clean, and then do yarn install.

This works for me sometimes. Other times, I have to follow up the yarn install with a yarn upgrade. Although slow, that seems to always fix it.

Using yarn version 0.27.5, which is the latest at this time. Using [email protected], @types/[email protected].

Diffing the yarn.lock file as it is under the error condition and as it is under the no-error condition shows no diff; in both cases, both versions of @types/request are 0.0.45.

I just updated the package version: sudo npm i @types/[email protected]

Was this page helpful?
0 / 5 - 0 ratings