-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
refactor(parser): Remove _bootstrap
method
#384
Conversation
94b46d0
to
4717e60
Compare
I’m a heavy user of the internals of parse5, including |
The arguments of The rationale behind this change: Afaict the original intention of |
That seems fine. I wanted to stress that I’m using the internals of parse5 to do some magic. While hacky and not pretty, I’d rather not see all internals hidden away. |
4717e60
to
ffa6722
Compare
@@ -82,7 +82,7 @@ export interface ParserOptions<T extends TreeAdapterTypeMap> { | |||
* | |||
* @default `true` | |||
*/ | |||
scriptingEnabled?: boolean | undefined; | |||
scriptingEnabled?: boolean; |
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.
Is it intentional that the value can’t be undefined
, but that the field can be missing?
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.
These values can still be explicitly undefined — I am honestly not sure why the | undefined
was here in the first place (this was copied from the previous @types package). My suspicion would be an older TS version?
The only difference is that now Required<>
works with the options.
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.
I know that DefinitelyTyped was adding explicit | undefined
to types, when they had ?
. They‘re planning to pull them apart: DefinitelyTyped/DefinitelyTyped@b24e5f6.
My recommendation is to add | undefined
if the value can be set to undefined
. And to use ?
when the field can be missing. And to use both, for both.
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.
Ahh, thanks for digging this up. Looks like the option is now called exactOptionalPropertyTypes
and is explicitly opt-in (no longer enabled with strict
): microsoft/TypeScript#44626
My intuition is that users enabling this flag wouldn't want to be able to pass undefined
here.
The
_bootstrap
method leaves the parser in a broken-by-design state, which requires us to use non-null assertions to make TS happy. This PR removes this method, moving its arguments to the constructor.This helps considerably with #377.