Content
@
0 reply
0 recast
2 reactions
Darryl Yeo 🛠️
@darrylyeo
Any TypeScript gurus in the house who can help me troubleshoot this? What am I fundamentally misunderstanding about type parameters / conditionals here?
8 replies
1 recast
11 reactions
typeof.eth 🔵
@typeof.eth
type: Type; should probably be type: T Still not gonna work, though, cause the transform function is gonna assume the returned object has optional a and b keys. You could cast the returned value to ToType<T> (https://tinyurl.com/27735582) or you could do some weird function overloading (https://tinyurl.com/mw2m4nuz)
1 reply
0 recast
1 reaction
Darryl Yeo 🛠️
@darrylyeo
Oops, yup 😆 Ideally I'd leverage TypeScript's inline control flow as much as possible since casting with `as` effectively disables type checking. Function overloading is super weird, but could be promising...
1 reply
0 recast
1 reaction