Skip to content

Lib.d.ts ClipboardEventInit does not match the W3C specification #28998

Closed
@Brcrwilliams

Description

@Brcrwilliams

TypeScript Version:
3.3.0-dev.20181212

Search Terms:
ClipboardEvent
ClipboardEventInit
clipboardData is null

Code

new ClipboardEvent('paste', { clipboardData: new DataTransfer() });

Expected behavior:
According to the W3C spec this should be a valid constructor.

Chromium currently does not initialize the clipboardData so it is currently impossible to create an ClipboardEvent and add data to it when using TypeScript with Chromium.

Actual behavior:
TS fails to compile with an error:

test.ts:1:31 - error TS2345: Argument of type '{ clipboardData: DataTransfer; }' is not assignable to parameter of type 'ClipboardEventInit'.
Object literal may only specify known properties, and 'clipboardData' does not exist in type 'ClipboardEventInit'.

1 new ClipboardEvent('paste', { clipboardData: new DataTransfer() });
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error.

Playground Link: https://www.typescriptlang.org/play/#src=new%20ClipboardEvent('paste'%2C%20%7B%20clipboardData%3A%20new%20DataTransfer()%20%7D)%3B%0D%0A

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions