Skip to content

Use checker for declaration emit of optional, uninitialised parameter properties#16497

Merged
sandersn merged 3 commits into
masterfrom
use-checker-for-decl-emit-of-optional-param-props
Jun 13, 2017
Merged

Use checker for declaration emit of optional, uninitialised parameter properties#16497
sandersn merged 3 commits into
masterfrom
use-checker-for-decl-emit-of-optional-param-props

Conversation

@sandersn
Copy link
Copy Markdown
Member

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 as public s: string | undefined, and the emitted constructor parameter is constructor(s?: string | undefined)

Fixes #15872

sandersn added 3 commits June 13, 2017 11:31
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
Comment thread src/compiler/checker.ts
!(getModifierFlags(parameter) & ModifierFlags.ParameterPropertyModifier);
}

function isOptionalUninitializedParameterProperty(parameter: ParameterDeclaration) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why does this have to be on the checker and not in utilites.ts say?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i see, you need isOptionalParameter

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Also for consistency; I think it would be really weird for two predicates that are almost opposites not to be next to each other.

@sandersn sandersn merged commit 9f69cd5 into master Jun 13, 2017
@sandersn sandersn deleted the use-checker-for-decl-emit-of-optional-param-props branch June 13, 2017 20:21
@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Jun 13, 2017

release-2.4 as well.

@sandersn
Copy link
Copy Markdown
Member Author

Done

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants