Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40405,6 +40405,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === SyntaxKind.ThisKeyword));
return state;
}
else if (isStringLiteral(node.left) && isStringLiteral(node.right) && operator !== SyntaxKind.EqualsToken) {
error(node, Diagnostics.Comparison_of_string_literals_is_not_allowed);
}

return state;
}
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -8519,5 +8519,9 @@
"'{0}' is not a valid meta-property for keyword 'import'. Did you mean 'meta' or 'defer'?": {
"category": "Error",
"code": 18061
},
"Comparison of string literals is not allowed.": {
"category": "Error",
"code": 18062
}
}
6 changes: 6 additions & 0 deletions tests/baselines/reference/stringComp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//// [tests/cases/compiler/stringComp.ts] ////

//// [stringComp.ts]


//// [stringComp.js]
Comment thread
johnfav03 marked this conversation as resolved.
4 changes: 4 additions & 0 deletions tests/baselines/reference/stringComp.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//// [tests/cases/compiler/stringComp.ts] ////

=== stringComp.ts ===

4 changes: 4 additions & 0 deletions tests/baselines/reference/stringComp.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//// [tests/cases/compiler/stringComp.ts] ////

=== stringComp.ts ===

Comment thread
johnfav03 marked this conversation as resolved.
3 changes: 3 additions & 0 deletions tests/cases/compiler/StringComp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if ("bar" <= "foo") {
console.log("Really?")
}
Empty file.
Loading