Fix ThisParameterType<T> type (#36013)

* Simplify ThisParameterType<T> type

* Add tests
This commit is contained in:
Anders Hejlsberg
2020-01-06 08:55:34 -10:00
committed by GitHub
parent 28319a541a
commit df3b5bbdab
5 changed files with 76 additions and 1 deletions
+1 -1
View File
@@ -298,7 +298,7 @@ declare var Function: FunctionConstructor;
/**
* Extracts the type of the 'this' parameter of a function type, or 'unknown' if the function type has no 'this' parameter.
*/
type ThisParameterType<T> = T extends (this: unknown, ...args: any[]) => any ? unknown : T extends (this: infer U, ...args: any[]) => any ? U : unknown;
type ThisParameterType<T> = T extends (this: infer U, ...args: any[]) => any ? U : unknown;
/**
* Removes the 'this' parameter from a function type.