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 Reverse<A> = | |
| `${A}` extends `${infer AH}${infer AT}` | |
| ? `${Reverse<AT>}${AH}` : A | |
| type Digs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
| type DigsNext<I = Digs, R = {}> = | |
| I extends [infer Head, infer Next, ...infer Tail] | |
| ? DigsNext<[Next, ...Tail], R & Record<Head, Next>> | |
| : { [K in keyof R]: R[K] } |
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 Reverse<A> = | |
| `${A}` extends `${infer AH}${infer AT}` | |
| ? `${Reverse<AT>}${AH}` : A | |
| type Digs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
| type DigsNext<I = Digs, R = {}> = | |
| I extends [infer Head, infer Next, ...infer Tail] | |
| ? DigsNext<[Next, ...Tail], R & Record<Head, Next>> |
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 Operations = 'sum' | 'sub' | 'mul' | 'div'; | |
| type RecursiveReturn = [number, (args: Array<number>, next?: Operations) => RecursiveReturn] | |
| const calculator = | |
| (operation: Operations, prev?: number) => | |
| (args: Array<number>, next?: Operations): RecursiveReturn => { | |
| const nums = prev === undefined ? [...args] : [...args, prev]; | |
| const partial = nums | |
| .reduce((prev: number, curr: number) => ({ | |
| ['sum']: prev + curr, |
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 GreaterThan< | |
| T extends number, | |
| U extends number, | |
| C extends unknown[] = [] | |
| > = | |
| T extends U | |
| ? false | |
| : C['length'] extends T | |
| ? false |
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 A = {foo: string}; | |
| type B = {bar: number}; | |
| type Module = A & B; | |
| type C = {something: () => string} | |
| type Store = Module & C; | |
| class Teste<S = Store> { | |
| sub<T extends keyof S>(key: T, cb: (value: S[T]) => void): void { | |
| } | |
| pub<T extends keyof S>(obj: {[T in keyof Partial<S> ]: S[T]} ): void { |
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 Numeros = ['zero', 'um', 'dois', 'tres', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove']; | |
| type Dezenas = ['','','vinte', 'trinta', 'quarenta', 'cinquenta', 'sessenta', 'setenta', 'oitenta', 'noventa']; | |
| type Cem = ['cem']; | |
| type Centenas = ['cento', 'duzentos', 'trezentos', 'quatrocentos', 'quinhentos', 'seiscentos', 'setecentos', 'oitocentos', 'novecentos']; | |
| type GetWords<Str extends string, Curr extends string = ''> = | |
| Str extends `${infer L}${infer R}` | |
| ? L extends ' ' | |
| ? Curr | |
| : GetWords<R, `${Curr}${L}`> |
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 Creator = | |
| <Name extends string, Args, Response> | |
| (name: Name, runner: (args: Args) => Response, subModule?: RCreator<Name, Args, Response>) => | |
| RCreator<Name, Args, Response> | |
| const createModule: Creator = (name, runner, subModule) => { | |
| return { | |
| ...subModule, |
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
| import type {Application} from './server' | |
| const client = () => { | |
| const call = <Args>(name: string, args: Args) => { | |
| // impl.... | |
| } | |
| return{ | |
| call | |
| } as Application | |
| } |
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 l = [...Array(100).keys()]; | |
| const fizz = (n) => (n % 3 === 0 ? "Fizz" : ""); | |
| const buzz = (n) => (n % 5 === 0 ? "Buzz" : ""); | |
| const fizzBuzzSolver = (number) => | |
| `${fizz(number)}${buzz(number)}` || "Nenhum"; | |
| l.forEach((number) => console.log(`${number}: ${fizzBuzzSolver(number)}`)); |
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 outer(props) { | |
| const self = this; | |
| self.outer = 'outer'; | |
| function inner(props, ctx) { | |
| const self = this; | |
| self.inner = 'inner'; | |
| ctx.outer = 'outer-malucao' | |
| return { | |
| inner: self.inner, | |
| ctx: ctx.outer, |