Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[ID-Prep] PR3 - Preserve parameter types for optional parameters /fields with undefined in type and for required params with default value #57484
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
[ID-Prep] PR3 - Preserve parameter types for optional parameters /fields with undefined in type and for required params with default value #57484
Changes from all commits
3e04102
85f60d9
a05d427
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
ensureType
is never called with aSetAccessorDeclaration
. The set accessor type does not have a return type and the parameter type is inferred independently. Removing this had 0 impact on tests.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 logic here is overly complicated. Both calls to
createTypeOfDeclaration
boil down to the same arguments. Also I have not found a test that benefits from the use ofcreateTypeOfExpression
on the initializer and I can't think of a case when this would help. (There might be some error case, but it's not tested for and returningany
for that seems just as appropriate.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.
Removed the
cleanup
closure. Since the logic is simpler now it's easier to just assign a variable and do the same cleanup after the switch.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.
isRequiredInitializedParameter
andisOptionalUninitializedParameterProperty
were used only once in the declaration transform in(resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node))
. I think it's worth simplifying the API and only expose a function taht tells us is the parameter requires adding an implcitundefined
to it's type or not.requiresAddingImplicitUndefined
also takes into account if the type already contains undefined and thus avoids re-printing types unless it's absolutely necessary. (Fixing #57483)