|
|
|
|
|
by Fedelaus
1709 days ago
|
|
I think the unknown example is good but also somewhat confusing, because implicit typing would understand what set of types could be in that array at that moment. Is there another example someone could give for unknown which isn't handled by implicit typing? |
|
BTW, TypeScript has another useful tool for tying the runtime typing and static typing together: type guards.
This is a boolean function but the type system understands that in codepaths where it returns true, the 'x' argument is known to have the UserRecord type. Great for codifying your type-discernment logic.