Closed
Description
lib Update Request
Configuration Check
My compilation target is es5
and my lib is the default
.
Missing / Incorrect Definition
The else clause of ReturnType is never reached because of the constraint so that it is reasonable to be never.
Sample Code
type T10 = ReturnType<() => string>; // string
>T10 : string
type T11 = ReturnType<(s: string) => void>; // void
>T11 : void
>s : string
type T12 = ReturnType<(<T>() => T)>; // {}
>T12 : unknown
type T13 = ReturnType<(<T extends U, U extends number[]>() => T)>; // number[]
>T13 : number[]
type T14 = ReturnType<typeof f1>; // { a: number, b: string }
>T14 : { a: number; b: string; }
>f1 : (s: string) => { a: number; b: string; }
type T15 = ReturnType<any>; // unknown
>T15 : unknown // changed from any
type T16 = ReturnType<never>; // never
>T16 : never
type T17 = ReturnType<string>; // Error
>T17 : never // changed from any
type T18 = ReturnType<Function>; // Error
>T18 : never // changed from any
type T19<T extends any[]> = ReturnType<(x: string, ...args: T) => T[]>; // T[]
>T19 : T[]
>x : string
>args : T
Documentation Link
https://www.typescriptlang.org/docs/handbook/utility-types.html#returntypetype
Changeset
I already made a changeset. I didn't know that a backlog issue is required to open a pull request.
Duplicates
A possible duplicate is #39584 but nothing is discussed there.