Skip to content

Fix implied constraints in conditional types - #22989

Merged
Anders Hejlsberg (ahejlsberg) merged 4 commits into
masterfrom
fixImpliedConstraint
Mar 30, 2018
Merged

Anders Hejlsberg (ahejlsberg) merged 4 commits into
masterfrom
fixImpliedConstraint

Conversation

@ahejlsberg

Copy link
Copy Markdown
Member

Fixes #22985.

Comment thread src/compiler/checker.ts
function getConstrainedTypeVariable(typeVariable: TypeVariable, node: Node) {
let constraints: Type[];
while (isPartOfTypeNode(node)) {
while (node && !isStatement(node)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is isExpression preferable to isStatement here?

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.

No, there might not be an enclosing expression anywhere in the parent chain.

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.

We could additionally check for !isExpression(node) but it isn't really necessary, we'll eventually hit a statement (which could be a declaration statement) or the very top node.

@ahejlsberg
Anders Hejlsberg (ahejlsberg) deleted the fixImpliedConstraint branch March 30, 2018 00:06
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jul 26, 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