-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Improve diagnostic message for negative old style octal literals #13056
Conversation
cf7051e
to
faf0bfe
Compare
@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'. |
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.
Looks good!
@@ -742,6 +742,11 @@ namespace ts { | |||
return false; | |||
} | |||
|
|||
export function isMinusPrefixUnaryExpression(node: Node): boolean { |
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.
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;
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.
Thank you for review, @mhegazy. I will update it.
faf0bfe
to
23faaff
Compare
Additional for #10101 and #13016