Skip to content

Conversation

@Richienb
Copy link
Contributor

Fixes #1230

Copy link
Collaborator

@fregante fregante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the type do exactly? There are no errors here:

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBDAnmApnAyjKwDGMCiAbigHYwAqAhlAOYrwBmUEIcA5AM5a4wC0KxMrxjU6MNgG4AUFJwQSXBKPpwAvHBIoA7nAAURUhWXxKHBMhQQGGbngNkqtegB4A3lICQDCBABccLmwSGgk4AHowuHt4LWAYAAs4ABNKESkAXwAaOABtTzYAI2o2bIiowRi4+IgAV3gUtIBdAD4ASmkZEScYADok4A4wVJx46N1NHQBhGq4WMbZvCDZW9qkusT6BoZgRsYm4admQecWSuFck+kpgABt-NnJ4lDZ0lel1+k3B4dGK8e0DjMYHM-mwSBBUGcLldbvdHs9XqsPr1+t8dr9DP8pkCQZiFj4oZcRLDzgAPfwAInBJgC3GCAH4KelER1kV9trs-vt5kUoMskcZ2T89gD5tTkigGMBNEk4AU6rTbjc4JQbjcIFoUEl6fyJEA

import type StrictEventTarget from 'strict-event-target';

const target = new (EventTarget as typeof StrictEventTarget<{
	foo: string; // Event with data
}, [
	'bar', // Event without data
]>);


target.dispatchEvent(new CustomEvent('foo'));
target.dispatchEvent(new CustomEvent('foo', {detail: 'The'}));
target.dispatchEvent(new CustomEvent('nope', {detail: 'The'}));
target.dispatchEvent(new CustomEvent('foo', {detail: {x: "not a string?"}}));

target.dispatchEvent(new Event('bar'));
target.dispatchEvent(new Event('not defined but still allowed?'));

@Richienb
Copy link
Contributor Author

There are no errors here:

Yeah so I wanna fix it here, and deprecate that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strict EventTarget

2 participants