Closed
Description
TypeScript Version: 2.5.2 ( and all prior version to latest )
Code
class Foo extends HTMLElement {
constructor() {
super()
this.attachShadow({mode:'open'})
}
emitCustomEvent() {
// error
this.shadowRoot.dispatchEvent(new Event('hello', {bubbles: true, composed: true}));
}
emitCustomEventWithExtractedConfig() {
const worldEventConfig = {bubbles: true, composed: true}
// no error --> ! this is strange behaviour of TSC, this should be error as well
this.shadowRoot.dispatchEvent(new Event('world', worldEventConfig));
}
}
Expected behavior:
{composed:boolean}
should be defined ( this event config flag is needed when triggering custom events from shadow root to pierce outside the shadow.
Also what is very strange is that, when event config is initialized to a variable and used then as a reference within Event
creation, TS won't throw error which is very strange behaviour indeed as from structure perspective, the composed
property is still there and not allowed by current dom.lib.ts
Actual behavior:
add {composed: boolean}
to Event and EventInit interfaces within dom.lib.ts