From 03c3a686df858308b977cad578c80d50b142e314 Mon Sep 17 00:00:00 2001 From: Nurbol Alpysbayev Date: Sun, 29 Jul 2018 00:21:42 +0600 Subject: [PATCH] Add Parameters type to core lib Here: https://github.com/Microsoft/TypeScript/issues/26019#issuecomment-408539886 I was recommended by @bterlson to add Parameters type to my lib.d.ts as well as ReturnType. When doing so, I found out that ReturnType is already lives in core lib.es5.d.ts. In my case I use Parameters much more than ReturnType, and I guess some other people do as well. So I thought both said types should be in core lib. --- src/lib/es5.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index c00f37c260de3..dd456df48334f 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1378,6 +1378,11 @@ type Extract = T extends U ? T : never; */ type NonNullable = T extends null | undefined ? never : T; +/** + * Obtain the parameters type of a function type + */ +type Parameters = T extends (... args: infer T) => any ? T : never; + /** * Obtain the return type of a function type */