-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Make Number and String literal types immutable. #28344
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
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.
You're got binary
and postfixUnary
expressions covered; but it looks like you're missing prefixUnary
, like ++a
.
@@ -21820,10 +21829,18 @@ namespace ts { | |||
|
|||
function checkBinaryLikeExpression(left: Expression, operatorToken: Node, right: Expression, checkMode?: CheckMode, errorNode?: Node): Type { | |||
const operator = operatorToken.kind; | |||
let leftType: Type; | |||
|
|||
const symbol = (<Identifier>left).escapedText ? getResolvedSymbol(left as Identifier) : undefined; |
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.
Use isEntityNameExpression
and not left.escapedText
(since checking a.b += 1
is also desireable. Also, a test for a.b += 1
would be good.
src/compiler/checker.ts
Outdated
@@ -21465,7 +21465,16 @@ namespace ts { | |||
} | |||
|
|||
function checkPostfixUnaryExpression(node: PostfixUnaryExpression): Type { | |||
const operandType = checkExpression(node.operand); | |||
let operandType: Type; | |||
const symbol = (<Identifier>node.operand).escapedText ? getResolvedSymbol(node.operand as Identifier) : undefined; |
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.
Use isEntityNameExpression
and not left.operand.escapedText
(since checking a.b++
is also desirable. Also, a test for a.b++
would be good.
a1dd0ae
to
56817c8
Compare
@weswigham Thank you! Addressed the feedback. Also added more tests for both |
No worries. Thanks for the update 🙂 |
Fixes #14745