help needed with types #12
-
hey everyone i am reading the froebel code base and learning so much |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi Danish, the The Most of the types in |
Beta Was this translation helpful? Give feedback.
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 namefun
from types.ts.The
Widen
type converts string unions to a genericstring
type and number unions to a genericnumber
. SoWiden<'a' | 'b'>
returns the typestring
instead of the union