Skip to content

Commit 0d06d37

Browse files
authored
fix: Emit a warning when attempting to use a template literal (#1702)
1 parent d4e7b9d commit 0d06d37

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/tokenizer.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,15 @@ export class Tokenizer extends DiagnosticEmitter {
10701070
var quote = text.charCodeAt(pos++);
10711071
var start = pos;
10721072
var result = "";
1073+
1074+
if (quote == CharCode.BACKTICK) {
1075+
this.warning(
1076+
DiagnosticCode.Not_implemented_0,
1077+
this.range(start - 1, end),
1078+
"Template Literals can only be used for multi-line strings. Interpolation is not supported."
1079+
);
1080+
}
1081+
10731082
while (true) {
10741083
if (pos >= end) {
10751084
result += text.substring(start, pos);

tests/parser/literals.ts

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
7_;
7171
1.a;
7272
2.0b;
73+
`123`;
7374

7475
// technically invalid, but not handled by AS yet, TS1005: ';' expected
7576
3 4;

tests/parser/literals.ts.fixture.ts

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ b;
6767
a;
6868
2;
6969
b;
70+
"123";
7071
3;
7172
4;
7273
5;
@@ -82,3 +83,4 @@ b;
8283
// ERROR 6188: "Numeric separators are not allowed here." in literals.ts(70,2+0)
8384
// ERROR 1351: "An identifier or keyword cannot immediately follow a numeric literal." in literals.ts(71,3+0)
8485
// ERROR 1351: "An identifier or keyword cannot immediately follow a numeric literal." in literals.ts(72,4+0)
86+
// WARNING 100: "Not implemented: Template Literals can only be used for multi-line strings. Interpolation is not supported." in literals.ts(73,1+102)

0 commit comments

Comments
 (0)