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

Make generate-js.js ts clean #430

Merged
merged 3 commits into from
Dec 6, 2023
Merged

Make generate-js.js ts clean #430

merged 3 commits into from
Dec 6, 2023

Conversation

markw65
Copy link

@markw65 markw65 commented Aug 28, 2023

While working on #429 I found that having @ts-check enabled on the new files was very helpful, so I decided to see how hard it would be to turn on for generate-js.js. This is the result.

I found several typing errors (either errors in jsdoc comments, or in peg.d.ts) - but these were just incorrect declarations - the code itself was fine (also, most of them were introduced by me, when I added source map support to generate-js.js).

I also found one possible bug (again, it was me that did it): A SourceNode was constructed with a child array consisting of strings and an array of SourceNodes (ie Array<string|Array<SourceNode>>). The type info says it should be a Array<string|SourceNode>. Apparently the code did work though, so who knows.

In any case, if this seems worthwhile, I'll be happy to put up similar pull requests for other files as I get time.

lib/peg.d.ts Outdated Show resolved Hide resolved
@hildjj
Copy link
Contributor

hildjj commented Sep 7, 2023

I think this is the next one I want to land. I'll look at it later today, but could you do a quick rebase please?

@markw65
Copy link
Author

markw65 commented Sep 7, 2023

Rebased

@hildjj hildjj self-requested a review September 7, 2023 17:23
lib/compiler/passes/generate-js.js Show resolved Hide resolved
lib/compiler/passes/generate-js.js Outdated Show resolved Hide resolved
lib/compiler/passes/generate-js.js Show resolved Hide resolved
lib/compiler/passes/generate-js.js Outdated Show resolved Hide resolved
lib/compiler/passes/generate-js.js Show resolved Hide resolved
lib/compiler/passes/generate-js.js Show resolved Hide resolved
lib/compiler/stack.js Show resolved Hide resolved
lib/peg.d.ts Outdated Show resolved Hide resolved
lib/peg.d.ts Outdated Show resolved Hide resolved
@reverofevil
Copy link

JFYI there's a full rewrite in TS here

Feel free to steal anything from there, as I don't have time to update it to most recent version

@markw65
Copy link
Author

markw65 commented Sep 8, 2023

@reverofevil Nice.

From my point of view a full typescript rewrite would be much better. But I'd assumed that sticking with code that "just works" without a build step was probably a project requirement. If thats not the case, then sure...

@reverofevil
Copy link

@markw65 Whether it's a full rewrite or not, we still have to figure out how to make types work, and it's the same in either case.

As far as I understand, you plan to continue cleaning up peggy's codebase. In that case feel free to take anything from a (differently) cleaned up version of peggy.

@markw65
Copy link
Author

markw65 commented Sep 13, 2023

@hildjj Is there anything else you want here? I have the changes to stack.js if you'd like me to roll those into this pull request; or I can do that separately.

@markw65
Copy link
Author

markw65 commented Sep 27, 2023

@hildjj ping

@hildjj
Copy link
Contributor

hildjj commented Oct 5, 2023

Sorry, have been traveling. Will get to this when I can, it's still first on the list.

@hildjj
Copy link
Contributor

hildjj commented Dec 3, 2023

And of course I didn't get to this in a timely fashion. Apologies. Looking at it now.

@hildjj
Copy link
Contributor

hildjj commented Dec 3, 2023

All this needs is a CHANGELOG.md entry, and it's ready to go.

@hildjj hildjj mentioned this pull request Dec 3, 2023
@hildjj hildjj merged commit 65cadae into peggyjs:main Dec 6, 2023
9 checks passed
@markw65 markw65 deleted the jsdoc-types branch December 7, 2023 20:17
@markw65 markw65 mentioned this pull request Dec 9, 2023
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