Skip to content

In getContextualTypeForBinaryOperand, only need to look for = assignment operator, not e.g. +=#20037

Merged
2 commits merged into
masterfrom
getContextualTypeForBinaryOperand
Nov 17, 2017
Merged

In getContextualTypeForBinaryOperand, only need to look for = assignment operator, not e.g. +=#20037
2 commits merged into
masterfrom
getContextualTypeForBinaryOperand

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Nov 15, 2017

isAssignmentOperator(operator) may have been used out of habit, but we don't really need contextual types for += since you can't do cb += (x, y) => { ... } or anything that would need a contextual type without introducing type errors, since it only works for numbers/strings.

@ghost ghost requested a review from sandersn November 15, 2017 15:56
Comment thread src/compiler/checker.ts Outdated
return getContextualType(binaryExpression);
}
}
function isNonContextualBinaryExpression(binaryExpression: BinaryExpression): boolean {
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.

flip to ContextSensitive as above

Comment thread src/compiler/checker.ts Outdated
}
return type;
// Don't do this for special property assignments to avoid circularity
return node !== right || isNonContextualBinaryExpression(binaryExpression) ? undefined : getTypeOfExpression(left);
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.

node === right && isContentSensitiveBinaryExpressin(binaryExpression) ? getTypeOfExpression(left) : undefined;

@ghost ghost force-pushed the getContextualTypeForBinaryOperand branch from c32af7b to a26e685 Compare November 16, 2017 15:09
@ghost ghost merged commit 46c0edc into master Nov 17, 2017
@ghost ghost deleted the getContextualTypeForBinaryOperand branch November 17, 2017 15:29
errendir added a commit to errendir/TypeScript that referenced this pull request Nov 20, 2017
* origin/master: (140 commits)
  test overriding Session.event
  Update editorServices.ts
  Fix semantic merge conflict (microsoft#20119)
  LEGO: check in for master to temporary branch.
  Moved minified file exclusion
  Fixed internal safelist
  For import completion, if multiple re-exports exist, choose the one with the shortest path (microsoft#20049)
  Bundle fileName with CodeActionCommand (microsoft#19881)
  Simplify documentHighlights (microsoft#20091)
  LEGO: check in for master to temporary branch.
  Support semantic classification of alias (microsoft#20012)
  In `getContextualTypeForBinaryOperand`, only need to look for `=` assignment operator, not e.g. `+=` (microsoft#20037)
  lineAction: Use an enum instead of true | false | undefined (microsoft#20086)
  LEGO: check in for master to temporary branch.
  cleanup NodeTypingsInstaller
  remove comments
  type `event` callback correctly
  update baselines
  defer callback and remove handler object
  Support arbitrary prototype property assignments in navigation bar (microsoft#19923)
  ...
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
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.

1 participant