-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response type incompatabile with pre 4.2 TypeScript, introduced in v3.1.0 #102
Comments
3.1.2 is still failing: tsc --lib 'es2015,dom' response-compatibility.ts response-compatibility.ts:3:35 - error TS2345: Argument of type '(response: Response) => Response' is not assignable to parameter of type '(value: Response) => Response | PromiseLike<Response>'.
Types of parameters 'response' and 'value' are incompatible.
Type 'import("/Users/ashulzhe/workspace/fetch_repro/node_modules/cross-fetch/lib.fetch").Response' is not assignable to type 'Response'.
The types returned by 'body.getReader(...).read(...)' are incompatible between these types.
Type 'Promise<ReadableStreamDefaultReadResult<Uint8Array>>' is not assignable to type 'Promise<ReadableStreamReadResult<T>>'.
Type 'ReadableStreamDefaultReadResult<Uint8Array>' is not assignable to type 'ReadableStreamReadResult<T>'.
Type 'ReadableStreamDefaultReadValueResult<Uint8Array>' is not assignable to type 'ReadableStreamReadResult<T>'.
Type 'ReadableStreamDefaultReadValueResult<Uint8Array>' is not assignable to type 'ReadableStreamReadValueResult<T>'.
Types of property 'value' are incompatible.
Type 'Uint8Array' is not assignable to type 'T'.
'Uint8Array' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'ArrayBufferView'.
3 fetch('https://www.example').then((response: Response) => {
~~~~~~~~~~~~~~~~~~~~~~~~~ |
Oh, just saw this line. Looks like those types are from later version of TypeScript. Tried running with TS 4.2.3: > node_modules/.bin/tsc -v
Version 4.2.3
> node_modules/.bin/tsc --lib 'dom,es2015' response-compatibility.ts
# compiles! |
@xenjke hey, thanks for reporting this issue. Can you run |
Hey @lquixada, thank you for the quick turnaround! I can confirm that |
Issue
Version 3.1.0 introduced a breaking change to
Response
type.Up to this version, Cross-Fetch response type was matching
Response
type from TypeScript TypesExample code
Compilation failure
Same example compiles fine with
cross-fetch
locked to 3.0.6.Environment
The text was updated successfully, but these errors were encountered: