Object literals use contextual type for this
when available and ignore type of literal itself.
#15157
Labels
this
when available and ignore type of literal itself.
#15157
Object literals with no contextual type use the type of the literal itself for
this
. However, when there is a contextual type, that gets used forthis
to the exclusion of the literal's own type. The type forthis
should actually be the intersection of the contextual type and the literal's own type.this.m()
should be of typeD
but is actually of typeB
.I don't know how important this is; the current behaviour is pretty good but it did break a couple of times in our real-world code base. See comments on the original PR #14141 for details. MockJax and an Angular test broke.
The text was updated successfully, but these errors were encountered: