Skip to content

Commit 23faaff

Browse files
committed
isMinusPrefixUnaryExpression() -> isPrefixUnaryExpression() after code review
1 parent db1fda5 commit 23faaff

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21865,7 +21865,7 @@ namespace ts {
2186521865
diagnosticMessage = Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
2186621866
}
2186721867
if (diagnosticMessage) {
21868-
const withMinus = isMinusPrefixUnaryExpression(node.parent);
21868+
const withMinus = isPrefixUnaryExpression(node.parent) && node.parent.operator === SyntaxKind.MinusToken;
2186921869
const literal = `${withMinus ? "-" : ""}0o${node.text}`;
2187021870
return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
2187121871
}

src/compiler/utilities.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,8 @@ namespace ts {
742742
return false;
743743
}
744744

745-
export function isMinusPrefixUnaryExpression(node: Node): boolean {
746-
return node.kind === SyntaxKind.PrefixUnaryExpression &&
747-
(node as PrefixUnaryExpression).operator === SyntaxKind.MinusToken;
745+
export function isPrefixUnaryExpression(node: Node): node is PrefixUnaryExpression {
746+
return node.kind === SyntaxKind.PrefixUnaryExpression;
748747
}
749748

750749
// Warning: This has the same semantics as the forEach family of functions,

0 commit comments

Comments
 (0)