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

Support top level initializer block #63

Merged

Conversation

kamiazya
Copy link
Contributor

@kamiazya kamiazya commented Jun 8, 2021

In peggy@1.1.0, the function of top level initializer block is added, and constants and functions can be defined in the module.

Utilizing this feature in ts-pegjs solves the problem of type definition that was previously imported from the outside with customHeader, such as defining interface and type.

see peggyjs/peggy#73

Additional commemt

I was wondering where to insert the top level initializer block, but now I insert it at the top as peggy does.

@mikeatlas
Copy link

Came here looking for support for this. @pjmolina Any chance you might consider merging and releasing this PR?

@mikeatlas
Copy link

Note that if you're using the javascript.peg example, yes this will work to copy over the top-level initializer block, but my tsc really doesn't like the plain JS in strict mode - looks like the block in the example might be best if rewritten with typescript typed functions that get top-leveled.

@pjmolina
Copy link
Contributor

pjmolina commented Jul 2, 2021

Thank you @kamiazya & @mikeatlas
Looks good to me. Merging.

@pjmolina pjmolina merged commit ccc87dd into metadevpro:master Jul 2, 2021
@kamiazya kamiazya deleted the support-top-level-initializer-block branch July 2, 2021 16:01
@mikeatlas
Copy link

Great! thanks @pjmolina @kamiazya 🙏

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