New answers tagged

0

I gave it another go, which achieves the same functionality type Transform<From, To> = ( value: From, index: number, entries: [unknown, From][] ) => To; type Choose<A, B> = A extends B ? A : B; const map = <From, To>(t: Transform<From, To>) => <Input extends Record<string, From>>(obj: Input) => ...


4

While it can sometimes be useful to expose only static members and not allow instances of your class to be constructed, I don't see what you're gaining by doing that here. But by not allowing multiple different ScannerInputs, you do lose out on the ability to have them operate on streams other than System.in. If you'd made a constructor public and the ...


1

It would be much easier for TS to infer the types if you put your callback in second place. I mean const map = obj => f => {} Also I slightly refactored your function in order to reduce complexity: type Primitives = string | number; const apply = < Key extends string, Value, >(obj: Record<Key, Value>) => <Result,>(...


Top 50 recent answers are included