Description
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