Skip to content

Improve diagnostic message for negative old style octal literals#13056

Merged
mhegazy merged 2 commits intomicrosoft:masterfrom
arusakov:improve_diagnostic_message_negative_octal_literal
Dec 21, 2016
Merged

Improve diagnostic message for negative old style octal literals#13056
mhegazy merged 2 commits intomicrosoft:masterfrom
arusakov:improve_diagnostic_message_negative_octal_literal

Conversation

@arusakov
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

@mihailik review please

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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

Comment thread src/compiler/utilities.ts Outdated
return false;
}

export function isMinusPrefixUnaryExpression(node: Node): boolean {
Copy link
Copy Markdown
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
Copy Markdown
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