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 for numeric mcdoc literals #1145

Merged
merged 13 commits into from
May 19, 2024

Conversation

NeunEinser
Copy link
Contributor

This makes numeric literal types more expressive in their type.

This makes checking these types against nodes a bit less cumbersome in my current related work.

@NeunEinser NeunEinser requested a review from SPGoding as a code owner May 14, 2024 21:06
@NeunEinser
Copy link
Contributor Author

Looks like there is a failing test now, because of the node type change. I'll wait until I have feedback if this is a desirable change until looking into how to fix those.

packages/mcdoc/src/binder/index.ts Outdated Show resolved Hide resolved
packages/mcdoc/src/binder/index.ts Outdated Show resolved Hide resolved
@SPGoding
Copy link
Member

SPGoding commented May 14, 2024

Overall I think this would be a good change.

@NeunEinser
Copy link
Contributor Author

I can't figure out how to fix the tests. From the output it looks like it tries to see if the current mcdoc exports are equivalent to what this branch would generate, but there is ofc an intentional mismatch. Not sure how to change the test data.

@SPGoding
Copy link
Member

You can set the environment variable SNAPSHOT_UPDATE=1 when running npm test or just delete the __snapshots__ folder and let npm test re-generate that. We should probably add this to README

@NeunEinser
Copy link
Contributor Author

NeunEinser commented May 14, 2024

It didn't re-generate __snapshots__/packages/core/test-out/service/Operations.spec.js, not sure why. Maybe it was removed in the meantime?

@SPGoding
Copy link
Member

It deleted __snapshots__/packages/core/test-out/service/Operations.spec.js, not sure why.

the source file was moved from service/ to common/ so that's just an orphan snapshot.

Copy link
Member

@SPGoding SPGoding left a comment

Choose a reason for hiding this comment

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

LGTM, would be nice if you can update the syntax for TYPED_NUMBER in the mcdoc spec (docs/user/mcdoc/index.adoc) as well. Something like this probably works but it's been a while since I've worked on that punctuation soup document:

<<t-typed-number>>::
	<<t-float>> ++[++`d` `D` `f` `F`++]++^?^ | +
	<<t-integer>> ++[++`b` `B` `l` `L` `s` `S`++]++^?^

@NeunEinser NeunEinser force-pushed the mcdoc-improvements branch from 0406ecc to c8a543b Compare May 15, 2024 06:34
@NeunEinser
Copy link
Contributor Author

(rebase, no new commits)

@NeunEinser NeunEinser changed the title Better type for numeric mcdoc literals 🔨 Better type for numeric mcdoc literals May 15, 2024
@TheAfroOfDoom TheAfroOfDoom self-requested a review May 16, 2024 05:01
@TheAfroOfDoom
Copy link
Contributor

requested myself as a non-blocking reviewer so i remember to look at this eventually

@NeunEinser NeunEinser force-pushed the mcdoc-improvements branch from 3bac386 to 4f6b14b Compare May 17, 2024 22:47
packages/mcdoc/src/binder/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@TheAfroOfDoom TheAfroOfDoom left a comment

Choose a reason for hiding this comment

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

couple smaller things. generally this seems like a good idea though, nice work 😸


@SPGoding what are your thoughts on removing /__snapshots__/** linguist-generated=true from .gitattributes?

i guess they technically are generated, but it'd be nice if they weren't auto not rendered in the Files changed view. i find myself definitely wanting to review each snapshot change for robustness


similarly, why is README.md set as linguist-generated=true?

Copy link
Contributor

Choose a reason for hiding this comment

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

i might prefer we move these file deletions into a separate PR that removes the orphaned snapshots? as-is in here it's almost implying that these mcdoc type changes caused these file diffs

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe more leg-work than is worth though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could revert the changes to these deleted files, just not sure if it's wanted.

Copy link
Contributor

Choose a reason for hiding this comment

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

eh its probably fine to keep as-is. would be nice if we eventually had a script to check for orphaned snapshots in GHA

packages/mcdoc/src/type/index.ts Show resolved Hide resolved
@SPGoding
Copy link
Member

what are your thoughts on removing /snapshots/** linguist-generated=true from .gitattributes?

i agree

similarly, why is README.md set as linguist-generated=true?

it used to have automatically generated contributor information. i guess we can remove this as well.

@NeunEinser NeunEinser force-pushed the mcdoc-improvements branch from 8550d8b to 29233ac Compare May 19, 2024 10:18
@misode misode merged commit 42dbc01 into SpyglassMC:main May 19, 2024
3 checks passed
@NeunEinser NeunEinser deleted the mcdoc-improvements branch May 25, 2024 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants