This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type TypeName<T> = | |
T extends string ? "string" : | |
T extends number ? "number" : | |
T extends boolean ? "boolean" : | |
T extends undefined ? "undefined" : | |
T extends Function ? "function" : | |
"object"; | |
type T0 = TypeName<string>; // "string" | |
type T1 = TypeName<"a">; // "string" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Person { | |
name: string; | |
age: number; | |
location: string; | |
} | |
type P1 = Person["name"]; // string | |
type P2 = string[][0]; // string | |
type P3 = string[]["length"]; // number | |
type P4 = [string]["length"]; // 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fibonacci(num) { | |
if (num <= 1) { | |
return 1; | |
} | |
return fibonacci(num - 1) + fibonacci(num - 2); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Plus1<A extends any[]> = [true, ...A]; | |
type Add<A extends any[], B extends any[]> = [...A, ...B]; | |
type Minus1<A extends any[]> = A extends readonly [any?, ...infer U] ? U : [...A]; | |
type Minus2<A extends any[]> = Minus1<Minus1<A>>; | |
// verify | |
type D = Plus1<A>; // [true, true, true, true] | |
type E = Minus1<A>; // [true, true] | |
type F = Minus2<A>; // [true] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SectionedListWrapper = styled.div<{ clickable?: boolean; bordered?: boolean }>` | |
display: flex; | |
flex-direction: column; | |
${padding.b('$8')} | |
${cond.if( | |
'clickable', | |
css` | |
> *:not(:first-child):hover { | |
cursor: pointer; |
NewerOlder