@techsavvytravvy@typescript It'll work if you explicitly type `utils`: https://t.co/MuIpFcIqqb... which is silly hence this feature request: https://t.co/RcUAJURxFx
TypeScript Challenge!!
1. is this code safe to compile? (TypeScript says no)
2. if yes, what is the best way to change the code so that it compiles? (without changing the logic obviously)
https://t.co/5aaE7Pfv9R
Is the return type here:
{ a: "x" | "y", b: "x" | "y" }
or
{ a: "x", b: "x" } | { a: "y", b: "y" }
?
Both are correct, but the latter is more precise. But the only way to get the latter is through combinatoric explosion
TypeScript Challenge!!
1. is this code safe to compile? (TypeScript says no)
2. if yes, what is the best way to change the code so that it compiles? (without changing the logic obviously)
https://t.co/5aaE7Pfv9R
@fernandorojo I think you can simplify the props type to `Pick<ViewProps, "children" | "className" | Extract<keyof ViewProps, `aria-${string}`>>` and then you don't need that `AriaKeys` type
@fernandorojo I think you can simplify the props type to `Pick<ViewProps, "children" | "className" | Extract<keyof ViewProps, `aria-${string}`>>` and then you don't need that `AriaKeys` type
now I realise it's pretty ironic that I say "not the intended usage of existential types" in the comment ๐ญ but I had to or else I would have been dragged how it's a bad idea xD
It's so cool how TypeScript has enabled non-type-theory programmers (me included) to come up with features that are well understood in type-theory... For example this person wants "anonymous type parameters" and that's exactly what existential types are! https://t.co/KjxXvsMgjO
good thing is now I can verify my typescript PR behavior against purescript...
(i used to think what I have is universally quantified types and that `<T> ((t: T) => T` should be same as `<T>(t: T) => T` but that's not the case)
okay I figured out how to write existentially quantified types in purescript... and look typescript is much better haha
also that means my types are existentially quantified which i was unsure about