Skip to content

help needed with types #12

Discussion options

You must be logged in to vote

Hi Danish,

the λ type is just a shortcut for a function type. So the type λ is equivalent to the type (...args: any[]) => any or in other words a function that takes any number of arguments and returns anything. The type can also take two optional parameters: The first one is a list of the arguments the function accepts and the second is the function's return type. I.e. λ<[a: number, b?: string], number> is equivalent to writing (a: number, b?: string) => number. The same type is also exported under the name fun from types.ts.

The Widen type converts string unions to a generic string type and number unions to a generic number. So Widen<'a' | 'b'> returns the type string instead of the union

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@danish-mehmood
Comment options

Answer selected by danish-mehmood
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants