4 ms·
You may want to deconstruct the value and use the original base value. This seems entirely logical, and consistent with most implementations in functional la
by louthy 10y ago
You may want to deconstruct the value and use the original base value. This seems entirely logical, and consistent with most implementations in functional languages (and I'd say makes TypeScript's implementation the poor one - although I haven't seen it myself to have an opinion on).
- naasking 10y ago> You may want to deconstruct the value and use the original base value. I think this is exactly right. Members can be declared visible only when viewing an object through a particular supertype, and you may simultaneously need to invoke methods from the supertype and the subtype.
- int_19h 10y agoThing is, in most cases, you don't want to do that. You just want to narrow the type. It's unfortunate that this isn't readily possible even by explicitly reusing the name - C# shadowing rules for locals preclude it. So you can't do something like `if (x is int x) { ... }`.