Use checker for declaration emit of optional, uninitialised parameter properties#16497
Merged
sandersn merged 3 commits intoJun 13, 2017
Merged
Conversation
Optional parameter properties create a property with a type that unions with undefined when strictNullChecks is on. This needs to be reflected in the generated declaration.
Improves declaration emit and code readability
mhegazy
reviewed
Jun 13, 2017
| !(getModifierFlags(parameter) & ModifierFlags.ParameterPropertyModifier); | ||
| } | ||
|
|
||
| function isOptionalUninitializedParameterProperty(parameter: ParameterDeclaration) { |
Contributor
There was a problem hiding this comment.
why does this have to be on the checker and not in utilites.ts say?
Contributor
There was a problem hiding this comment.
i see, you need isOptionalParameter
Member
Author
There was a problem hiding this comment.
Also for consistency; I think it would be really weird for two predicates that are almost opposites not to be next to each other.
mhegazy
approved these changes
Jun 13, 2017
Contributor
|
release-2.4 as well. |
Member
Author
|
Done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The declaration emitter now uses the checker for emitting the type of optional, uninitialised parameter properties when strictNullChecks is on. This means that a parameter property like
constructor(public s?: string)is emitted aspublic s: string | undefined, and the emitted constructor parameter isconstructor(s?: string | undefined)Fixes #15872