Idea: Type Unpackers for Function Parameters
See original GitHub issueBecause of TypeScript 2.8 Conditional Types, we can now do the following:
type Param0<Func> = Func extends (a: infer T, ...args: any[]) => any
? T
: never;
type T0 = Param0<() => void>; // {}
type T1 = Param0<(a: number) => void>; // number
type T2 = Param0<(a: string[]) => void>; // string[]
Issue for discussion!
Questions:
- Naming scheme?
- Multiple Parameter Unpacks at the same time?
See also ReturnType<Func>
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
Unpack to function parameters - c++ - Stack Overflow
Is it theoretically possible to add a language feature to unpack structures into the function actual parameter lists? I mean the following.
Read more >Packing and unpacking parameters - Google Groups
For passing parameters to functions I want to pack them into a vector p, ... I can write two functions p = pack(a,b,c)...
Read more >A Guide to Args, Kwargs, Packing and Unpacking in Python
Before we get more into packing and unpacking values in Python, let's talk a little more about function arguments. There are 2 kinds...
Read more >Extract Parameter | IntelliJ IDEA Documentation - JetBrains
The Extract Parameter refactoring lets you extract a new parameter to a method. You can also use the Extract Functional Parameter ...
Read more >Using Python Optional Arguments When Defining Functions
The double star is used to unpack items from a mapping. A mapping is a data type that has paired values as items,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
On second thought you may be right about performance being a concern… I agree it might be better to play it safe.
Parameters are the declared inputs of a function signature, arguments are the runtime objects passed to a function:
https://stackoverflow.com/questions/156767/whats-the-difference-between-an-argument-and-a-parameter
I really doubt there’s much performance difference.