-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[lexical-markdown] Refactor: Update regExpEnd optional type in MultilineElementTransformer #6919
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hi @untilhamza! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
size-limit report 📦
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why you would use optional?: true
is to make it clear that the default is false, and that there's no reason to specify it otherwise. I'm not sure this really has any benefit, there are other places in the code where an optional true
is used as the type (such as discrete?: true
and skipTransforms?: true
), so if this change was desired I would expect that it would be done to the whole project. Does anyone else have opinions on this? @zurfyx @ivailop7
Generally speaking it's best to use types to limit the number of possible runtime states that should to be considered. {x?: boolean}
has 4 states and {x?: true}
has 3 (one less each when exactOptionalPropertyTypes
is used)
@etrepum , this is actually very insightful - thank you. However I did not know the default was false as I could not tell from just looking at the types. Is there a way to explicitly tell the user of the function that the default is false while keeping the type as |
The type itself already says that either the setting doesn't mean anything at all, or the default is not true. What you could do to make it more explicit for people who don't understand that implication is to add more documentation to the type. |
I see what you mean. I will close this PR for now. Thanks for sharing the thinking behind it. |
[lexical-markdown] Refactor: Broaden regExpEnd optional type to boolean
Description
Current Behavior:
In the MultilineElementTransformer interface, the
regExpEnd
property'soptional
field was unnecessarily restricted to only accepttrue
as a value. This strict typing didn't provide any practical benefit and limited potential use cases wherefalse
might be a valid state.Changes:
optional
inregExpEnd
fromtrue
toboolean
Closes #[issue number]
Test plan
Before
The
regExpEnd
type was overly restrictive:After
The
regExpEnd
type now allows both true and false values:This change maintains backward compatibility while providing more flexibility in how the optional flag can be used.