Skip to content

Retain literal type for prefix plus on number literal#17425

Merged
DanielRosenwasser merged 2 commits into
microsoft:masterfrom
ikatyang:fix-17392
Aug 3, 2017
Merged

Retain literal type for prefix plus on number literal#17425
DanielRosenwasser merged 2 commits into
microsoft:masterfrom
ikatyang:fix-17392

Conversation

@ikatyang
Copy link
Copy Markdown
Contributor

Fixes #17392

@msftclas
Copy link
Copy Markdown

@ikatyang,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by Microsoft. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

Comment thread src/compiler/checker.ts Outdated
if (isOperandNumericLiteral && node.operator === SyntaxKind.MinusToken) {
return getFreshTypeOfLiteralType(getLiteralType(-(<LiteralExpression>node.operand).text));
}
if (isOperandNumericLiteral && node.operator === SyntaxKind.PlusToken) {
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.

Can you fold these into one check for node.operand.kind === SyntaxKind.NumericLiteral?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I forgot I could write that way. 😅

@ikatyang
Copy link
Copy Markdown
Contributor Author

@DanielRosenwasser done

@DanielRosenwasser DanielRosenwasser merged commit 1552761 into microsoft:master Aug 3, 2017
@DanielRosenwasser
Copy link
Copy Markdown
Member

DanielRosenwasser commented Aug 3, 2017

Thanks @ikatyang!

@ikatyang ikatyang deleted the fix-17392 branch August 3, 2017 02:08
@DanielRosenwasser
Copy link
Copy Markdown
Member

I guess this also fixed #15346.

@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