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

Better type checking for visitor #437

Merged
merged 4 commits into from
Dec 9, 2023
Merged

Conversation

markw65
Copy link

@markw65 markw65 commented Sep 9, 2023

I noticed some of the checking was just string rather than the actual node types.

This ensures that every node type is actually implemented in the visitor by checking that the set of "visited" types matches the set of declared types.

It looks like we could also just look at ReturnType<typeof visit> which will be any if we missed any node types in the visitor, and void otherwise. But it would be hard (I think) to generate a meaningful error beyond "not all the node types were handled".

@hildjj
Copy link
Contributor

hildjj commented Dec 9, 2023

this one next, please.

@hildjj hildjj merged commit fe34d94 into peggyjs:main Dec 9, 2023
9 checks passed
@markw65 markw65 deleted the visitor-types branch December 10, 2023 20:47
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.

2 participants