Skip to content

Commit e08f2a3

Browse files
committed
Update InstanceType as well
1 parent 0a2d583 commit e08f2a3

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/lib/es5.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ type ReturnType<T extends (...args: never) => any> = T extends (...args: never)
16181618
/**
16191619
* Obtain the return type of a constructor function type
16201620
*/
1621-
type InstanceType<T extends abstract new (...args: any) => any> = T extends abstract new (...args: any) => infer R ? R : any;
1621+
type InstanceType<T extends abstract new (...args: never) => any> = T extends abstract new (...args: never) => infer R ? R : any;
16221622

16231623
/**
16241624
* Convert string literal type to uppercase

tests/baselines/reference/inferTypes1.errors.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
inferTypes1.ts(36,23): error TS2344: Type 'string' does not satisfy the constraint '(...args: never) => any'.
22
inferTypes1.ts(37,23): error TS2344: Type 'Function' does not satisfy the constraint '(...args: never) => any'.
33
Type 'Function' provides no match for the signature '(...args: never): any'.
4-
inferTypes1.ts(43,25): error TS2344: Type 'string' does not satisfy the constraint 'abstract new (...args: any) => any'.
5-
inferTypes1.ts(44,25): error TS2344: Type 'Function' does not satisfy the constraint 'abstract new (...args: any) => any'.
6-
Type 'Function' provides no match for the signature 'new (...args: any): any'.
4+
inferTypes1.ts(43,25): error TS2344: Type 'string' does not satisfy the constraint 'abstract new (...args: never) => any'.
5+
inferTypes1.ts(44,25): error TS2344: Type 'Function' does not satisfy the constraint 'abstract new (...args: never) => any'.
6+
Type 'Function' provides no match for the signature 'new (...args: never): any'.
77
inferTypes1.ts(55,25): error TS2344: Type '(x: string, y: string) => number' does not satisfy the constraint '(x: any) => any'.
88
Target signature provides too few arguments. Expected 2 or more, but got 1.
99
inferTypes1.ts(56,25): error TS2344: Type 'Function' does not satisfy the constraint '(x: any) => any'.
@@ -71,11 +71,11 @@ inferTypes1.ts(153,40): error TS2322: Type 'T' is not assignable to type 'string
7171
type U12 = InstanceType<never>; // never
7272
type U13 = InstanceType<string>; // Error
7373
~~~~~~
74-
!!! error TS2344: Type 'string' does not satisfy the constraint 'abstract new (...args: any) => any'.
74+
!!! error TS2344: Type 'string' does not satisfy the constraint 'abstract new (...args: never) => any'.
7575
type U14 = InstanceType<Function>; // Error
7676
~~~~~~~~
77-
!!! error TS2344: Type 'Function' does not satisfy the constraint 'abstract new (...args: any) => any'.
78-
!!! error TS2344: Type 'Function' provides no match for the signature 'new (...args: any): any'.
77+
!!! error TS2344: Type 'Function' does not satisfy the constraint 'abstract new (...args: never) => any'.
78+
!!! error TS2344: Type 'Function' provides no match for the signature 'new (...args: never): any'.
7979
type U15 = InstanceType<typeof Abstract>; // Abstract
8080
type U16<T extends any[]> = InstanceType<new (x: string, ...args: T) => T[]>; // T[]
8181
type U17<T extends any[]> = InstanceType<abstract new (x: string, ...args: T) => T[]>; // T[]

tests/baselines/reference/inferTypesBuiltinHelpers.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ type _1 = ReturnType<(...args: never) => 'foo'>
88
>args : never
99

1010
type _2 = InstanceType<new (...args: never) => 'foo'>
11-
>_2 : any
11+
>_2 : "foo"
1212
>args : never
1313

0 commit comments

Comments
 (0)