Skip to content

statically declare all parser methods #101

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

Merged
merged 2 commits into from
Jun 3, 2019
Merged

Conversation

Toxicable
Copy link
Contributor

This change, while bloating the file a lot, will translate to better type support both when refactoring and when Types are shipped from the source.

Also i've added strongly typed methods bitN(bitSize: 1|2|3...) and primitiveN(type: 'uint8' | 'uint16' ....
Which I think are a bit easier to and dynamic for people downstream of these functions when writing dynamic parsers.
Even those these are private they could be promoted to public.

@keichi
Copy link
Owner

keichi commented Jun 3, 2019

You're right, this is definitely better. Does TypeScript have macros? It would be great if we could generate the boilerplate code at compile time.

@Toxicable
Copy link
Contributor Author

Unfortunately no macros in TS
This is why I at least left the implementation of these methods to a single function so if anything needs to be changed the API facing functions shouldn't have to change.

@keichi
Copy link
Owner

keichi commented Jun 3, 2019

I see... we could still automatically generate these codes with external tooling, but let's not over-complicate things.

@keichi keichi merged commit 043f442 into keichi:master Jun 3, 2019
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