Skip to content

Improve diagnostic message for negative old style octal literals #13056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

arusakov
Copy link
Contributor

@arusakov arusakov commented Dec 20, 2016

Additional for #10101 and #13016

@arusakov arusakov force-pushed the improve_diagnostic_message_negative_octal_literal branch from cf7051e to faf0bfe Compare December 20, 2016 15:32
@arusakov arusakov changed the title Improve diagnostic message for negative old style literals Improve diagnostic message for negative old style octal literals Dec 20, 2016
@arusakov
Copy link
Contributor Author

@mihailik review please

@@ -3,7 +3,7 @@ tests/cases/conformance/expressions/literals/literals.ts(9,17): error TS2363: Th
tests/cases/conformance/expressions/literals/literals.ts(10,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/literals/literals.ts(10,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/literals/literals.ts(20,9): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o1'.
tests/cases/conformance/expressions/literals/literals.ts(25,10): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o3'.
tests/cases/conformance/expressions/literals/literals.ts(25,9): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '-0o3'.
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good!

@@ -742,6 +742,11 @@ namespace ts {
return false;
}

export function isMinusPrefixUnaryExpression(node: Node): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

i would rather this would be isPrefixUniraryExpresssion that is a type guard, i.e.

function isPrefixUniraryExpresssion (node: Node): node is PrefixUnaryExpression {
    return node.kind === SyntaxKind.PrefixUnaryExpression;
}

And used as

 const withMinus = isPrefixUniraryExpresssion(node.parent) && node.parent.operator === SyntaxKind.MinusToken;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for review, @mhegazy. I will update it.

@arusakov arusakov force-pushed the improve_diagnostic_message_negative_octal_literal branch from faf0bfe to 23faaff Compare December 21, 2016 22:02
@mhegazy mhegazy merged commit 445cf0e into microsoft:master Dec 21, 2016
@mhegazy mhegazy mentioned this pull request Dec 22, 2016
@arusakov arusakov deleted the improve_diagnostic_message_negative_octal_literal branch December 22, 2016 06:46
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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.

5 participants