Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessagePort#onmessage type changed in @types/[email protected] #1860

Open
yume-chan opened this issue Dec 7, 2024 · 0 comments
Open

MessagePort#onmessage type changed in @types/[email protected] #1860

yume-chan opened this issue Dec 7, 2024 · 0 comments

Comments

@yume-chan
Copy link
Contributor

In @types/[email protected], both events are MessageEvents:

const port = new MessagePort();

port.onmessage = (event) => {
  console.log(event.data)
}

port.addEventListener('message', event => {
  console.log(event.data)
})

Playground: https://www.typescriptlang.org/play/?lib=lib.esnext.d.ts&ts=5.7.2#code/PTAEAEBsEsCMC5QFMDOA7JAPALgKF9ALYAOA9gE7agDk42AnsasAIYCuAJtKQO4UDWkJNmoBuUCFAMmKRAAYAdIoBsAFnwBjUmhRUylUAF5QGHqACyqFCwDmSAAoVsACgCUo-PuwLthK7aQjUGckADckNGxXIwA+UABvXFBQLR1SIQVIUhsQ8MiFDhZsFldcAF9PJwUWDg4AUTzsABloXQikcmdqPxRrO2oAGmRG2ISklO0UdKRM7NyI70Li0rLXIA


In @types/[email protected], the event in onmessage becomes Event:

const port = new MessagePort();

port.onmessage = (event) => {
  console.log(event.data) // Property 'data' does not exist on type 'Event'. (2339)
}

port.addEventListener('message', event => {
  console.log(event.data)
})

Playground: https://www.typescriptlang.org/play/?lib=lib.esnext.d.ts&ts=5.7.2#code/PTAEAEBsEsCMC5QFMDOA7JAPALgKF9ALYAOA9gE7agDk42AnsasAIYCuAJtKQO4UDWkJNmoBuUCFAMmKRAAYAdIoBsAVnwBjUmhRUylUAF5QGHqACyqFCwDmSAAoVsACgCUo-PuwLthK7aQjUGckADckNGxXIwA+UABvXFBQLR1SIQVIUhsQ8MiFDhZsFmjJe3JSJkp6GkLi6lAOUlQTUiosaF1QbSlGQOoAUTyRBWCAJgBmCYBOV1wAX08nBRYODiGI7AAZTuwIpHJnaj8UaztqABpkYdiEpJTtFHSkTOzczYKikoXXIA


Is it intended?

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

No branches or pull requests

1 participant