@mattpocockuk @ArmandSalle You can also do it inline if you need
type ResultA = One extends infer O ? O extends any ? { [K in keyof O]: K extends 'c' ? number : O[K] } : never : never
Hey @mattpocockuk, how would you define the default function argument when using a generic? I can't seem to find the correct way.
function test<T extends "a" | "b">(input: T = "a"): T {
return input
}
// Error - T can be instantiated with different type than "a" - test<"b">
@mattpocockuk There is the option to use
function test<T extends "a" | "b">(input: T | "a" = "a"): T | "a" {
return input
}
but that changes the type of input inside and the return type... :sad:
been playing with inferring TS types from JSON schema definitions after reading through some of @mattpocockuk TS type tips & tricks, here is the current progress
https://t.co/gzEILVbC2D
@dan_abramov Great article, could you please elaborate on 2 things. Is it required to use useState for the prev value or could that be replaced with useRef? And secondly, since the derived state doesn't actually render children, could we just return null in the if statement?