Alternative of Function
Function vs (...args: Array<any>) => any
values |
Function |
() => any |
(arg: any) => any |
(arg1: any, arg2: any) => any |
(...args: Array<any>) => any |
|---|---|---|---|---|---|
Function |
✅ | ❌ | ❌ | ❌ | ❌ |
() => any |
✅ | ✅ | ✅ | ✅ | ✅ |
(arg: any) => any |
✅ | ❌ | ✅ | ✅ | ✅ |
(arg1: any, arg2: any) => any |
✅ | ❌ | ❌ | ✅ | ✅ |
(...args: Array<any>) => any |
✅ | ✅ | ✅ | ✅ | ✅ |
Alternative of object
{} vs object vs Object vs Record<string, unknown> vs Record<PropertyKey, unknown>
values |
{} |
object |
Object |
Record<string, unknown> |
Record<PropertyKey, unknown> |
|---|---|---|---|---|---|
{} |
✅ | ✅ | ✅ | ✅ | ✅ |
[] |
✅ | ✅ | ✅ | ❌ | ❌ |
() => undefined (Function) |
✅ | ✅ | ✅ | ❌ | ❌ |
new String('') (String) |
✅ | ✅ | ✅ | ❌ | ❌ |
new Number(1) (Number) |
✅ | ✅ | ✅ | ❌ | ❌ |
new Boolean(false) (Boolean) |
✅ | ✅ | ✅ | ❌ | ❌ |
a (string) |
✅ | ❌ | ✅ | ❌ | ❌ |
1 (number) |
✅ | ❌ | ✅ | ❌ | ❌ |
Symbol('symbol') (symbol) |
✅ | ❌ | ✅ | ❌ | ❌ |
null (null) |
❌ | ❌ | ❌ | ❌ | ❌ |
undefined (undefined) |
❌ | ❌ | ❌ | ❌ | ❌ |
abc (ABC: {a: string; b: number; c: boolean}) |
✅ | ✅ | ✅ | ✅ | ✅ |
abc (interface ABC) |
✅ | ✅ | ✅ | ❌ | ❌ |
abc (type ABC) |
✅ | ✅ | ✅ | ✅ | ✅ |
abc (class ABC) |
✅ | ✅ | ✅ | ❌ | ❌ |
abc (Record<string, unknown>) |
✅ | ✅ | ✅ | ✅ | ✅ |
abc (Record<PropertyKey, unknown>) |
✅ | ✅ | ✅ | ✅ | ✅ |
abc.a (access property) |
❌ | ❌ | ❌ | ✅ | ✅ |
Dictionary of Type
Make all properties in ObjectType optional
NaN is also Falsy, but TypeScript doesn't have a numeric literal.
https://github.com/Microsoft/TypeScript/issues/15135
HTMLAllCollection is also Falsy, but it's a deprecated feature.
Also, !!HTMLAllCollection is inferred as true in TypeScript.
https://developer.mozilla.org/en-US/docs/Web/API/Document/all
Convert all the optional properties in Base with undefined type
Extract the keys from a type where the value type of the key extends the given Condition.
Internally this is used for the ConditionalPick and ConditionalExcept types.
Get all optional properties
Get all required properties
Make type as Invariant
Make type as Invariant deeply
Generated using TypeDoc
Alternative of
anyhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#javascript_types