Skip to content

{composed:boolean} is missing in Event and EventInit interface within lib.dom.d.ts #18233

Closed
@Hotell

Description

@Hotell

TypeScript Version: 2.5.2 ( and all prior version to latest )

Code

see error in TS playground

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions