Skip to content

Fix typing in asyncDataTree.test.ts #209394

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

a-stewart
Copy link
Contributor

In asyncDataTree.test.ts we call container.querySelector which returns Element | null, and we cast this to HTMLElement | undefined and then do an equality check against undefined.

Whilst this works since null == undefined, the typing does make it slightly unclear what we actually have here, and when running with our stricted test setup, the test actually fails.

There is no technical reason to accept this PR, but casting to HTMLElement | null is slightly more correct and may avoid issues in the future if you ever want to to do other checks, eg child !== undefined would always be true which could potentially hide issues.

@jrieken jrieken assigned joaomoreno and unassigned jrieken Apr 3, 2024
@a-stewart a-stewart marked this pull request as ready for review April 4, 2024 00:15
@a-stewart
Copy link
Contributor Author

Small ping @joaomoreno

@joaomoreno
Copy link
Member

Why not simply removing the type casts? The compiler should be happy by now.

@a-stewart
Copy link
Contributor Author

@joaomoreno :
Why not simply removing the type casts? The compiler should be happy by now.

Done

@a-stewart
Copy link
Contributor Author

@joaomoreno - could this be merged please - I think it needs reapproval after making your suggested changes

@joaomoreno
Copy link
Member

Thanks! 🍻

@joaomoreno joaomoreno enabled auto-merge (squash) June 26, 2025 07:47
@vs-code-engineering vs-code-engineering bot added this to the June 2025 milestone Jun 26, 2025
@DoiDoi888
Copy link

In asyncDataTree.test.ts we call container.querySelector which returns Element | null, and we cast this to HTMLElement | undefined and then do an equality check against undefined.

Whilst this works since null == undefined, the typing does make it slightly unclear what we actually have here, and when running with our stricted test setup, the test actually fails.

There is no technical reason to accept this PR, but casting to HTMLElement | null is slightly more correct and may avoid issues in the future if you ever want to to do other checks, eg child !== undefined would always be true which could potentially hide issues.

https://skynet.certik.com/zh-CN/projects/uniswap?utm_source=okx#vote

@a-stewart
Copy link
Contributor Author

a-stewart commented Jul 1, 2025

@hediet @joaomoreno - I don't think I have permissions to merge this myself - you have approved but I think one of you need to press the button to merge it in.

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.

5 participants