Skip to content

Change (Node | null)[] return types to Node[]#4283

Merged
amaanq merged 1 commit intotree-sitter:masterfrom
tmr232:web-binding-better-types
Mar 15, 2025
Merged

Change (Node | null)[] return types to Node[]#4283
amaanq merged 1 commit intotree-sitter:masterfrom
tmr232:web-binding-better-types

Conversation

@tmr232
Copy link
Contributor

@tmr232 tmr232 commented Mar 12, 2025

In the rewrite for web-tree-sitter 0.25, some functions that used to return Node[] were changed to (Node | null)[].
This makes using them tricky, as it requires filtering out the null values.

But from what I gather - they don't actually return null values now either.

Given the way the C part is written, if I understand correctly, those functions should always return a Node[], and have no null elements.

This PR adds non-null assertions to change those type signatures and make using the functions the same as with previous versions.

@tmr232 tmr232 marked this pull request as ready for review March 12, 2025 16:06
Copy link
Contributor

@maxbrunsfeld maxbrunsfeld left a comment

Choose a reason for hiding this comment

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

Thank you!

@maxbrunsfeld
Copy link
Contributor

It looks like some type assertions in the tests are no longer necessary. Could you remove those, so that the lint passes for the tests?

@tmr232 tmr232 force-pushed the web-binding-better-types branch from 6764a36 to 1a71593 Compare March 15, 2025 06:17
@tmr232
Copy link
Contributor Author

tmr232 commented Mar 15, 2025

@maxbrunsfeld Done. npm run lint now passes on my machine.

@amaanq amaanq merged commit a380e1a into tree-sitter:master Mar 15, 2025
14 checks passed
@amaanq
Copy link
Member

amaanq commented Mar 15, 2025

thanks @tmr232!

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.

3 participants