Change WidgetType.updateDOM from type to this #81
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "from-this"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
With
thisTypeScript understands that it's the same type as the subclass.The
thistype means more than just "of the same class asthis" in TypeScript, unfortunately. It asserts that the value is actually equal tothis, and will cause weird type narrowing to happen. So unfortunately, though I agree it would be better to have a more precise type for this parameter,thisisn't appropriate here.I'm not sure that's the case? Do you have an example for the "weird type narrowing" because I can't manage to reproduce it:
TS Playground
It seems you are right. I distinctly remember giving up on
thisin the past because it misbehaved, but I cannot reproduce the problem in this case. The docs claim that it just dynamically takes the type of the current class, which seems safe. Let's try this then.