-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for symbol types in template expressions
- Loading branch information
1 parent
c12fc0d
commit fc08ff5
Showing
6 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/noImplicitSymbolToString.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
tests/cases/compiler/noImplicitSymbolToString.ts(6,30): error TS2352: Type 'symbol' cannot be converted to type 'string'. | ||
tests/cases/compiler/noImplicitSymbolToString.ts(7,30): error TS2469: The '+' operator cannot be applied to type 'symbol'. | ||
tests/cases/compiler/noImplicitSymbolToString.ts(8,8): error TS2469: The '+=' operator cannot be applied to type 'symbol'. | ||
|
||
|
||
==== tests/cases/compiler/noImplicitSymbolToString.ts (3 errors) ==== | ||
// Fix #19666 | ||
|
||
let symbol!: symbol; | ||
let str = "hello "; | ||
|
||
const templateStr = `hello ${symbol}`; | ||
~~~~~~ | ||
!!! error TS2352: Type 'symbol' cannot be converted to type 'string'. | ||
const appendStr = "hello " + symbol; | ||
~~~~~~ | ||
!!! error TS2469: The '+' operator cannot be applied to type 'symbol'. | ||
str += symbol; | ||
~~~~~~ | ||
!!! error TS2469: The '+=' operator cannot be applied to type 'symbol'. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//// [noImplicitSymbolToString.ts] | ||
// Fix #19666 | ||
|
||
let symbol!: symbol; | ||
let str = "hello "; | ||
|
||
const templateStr = `hello ${symbol}`; | ||
const appendStr = "hello " + symbol; | ||
str += symbol; | ||
|
||
|
||
//// [noImplicitSymbolToString.js] | ||
// Fix #19666 | ||
var symbol; | ||
var str = "hello "; | ||
var templateStr = "hello " + symbol; | ||
var appendStr = "hello " + symbol; | ||
str += symbol; |
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/noImplicitSymbolToString.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
=== tests/cases/compiler/noImplicitSymbolToString.ts === | ||
// Fix #19666 | ||
|
||
let symbol!: symbol; | ||
>symbol : Symbol(symbol, Decl(noImplicitSymbolToString.ts, 2, 3)) | ||
|
||
let str = "hello "; | ||
>str : Symbol(str, Decl(noImplicitSymbolToString.ts, 3, 3)) | ||
|
||
const templateStr = `hello ${symbol}`; | ||
>templateStr : Symbol(templateStr, Decl(noImplicitSymbolToString.ts, 5, 5)) | ||
>symbol : Symbol(symbol, Decl(noImplicitSymbolToString.ts, 2, 3)) | ||
|
||
const appendStr = "hello " + symbol; | ||
>appendStr : Symbol(appendStr, Decl(noImplicitSymbolToString.ts, 6, 5)) | ||
>symbol : Symbol(symbol, Decl(noImplicitSymbolToString.ts, 2, 3)) | ||
|
||
str += symbol; | ||
>str : Symbol(str, Decl(noImplicitSymbolToString.ts, 3, 3)) | ||
>symbol : Symbol(symbol, Decl(noImplicitSymbolToString.ts, 2, 3)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
=== tests/cases/compiler/noImplicitSymbolToString.ts === | ||
// Fix #19666 | ||
|
||
let symbol!: symbol; | ||
>symbol : symbol | ||
|
||
let str = "hello "; | ||
>str : string | ||
>"hello " : "hello " | ||
|
||
const templateStr = `hello ${symbol}`; | ||
>templateStr : string | ||
>`hello ${symbol}` : string | ||
>symbol : symbol | ||
|
||
const appendStr = "hello " + symbol; | ||
>appendStr : string | ||
>"hello " + symbol : string | ||
>"hello " : "hello " | ||
>symbol : symbol | ||
|
||
str += symbol; | ||
>str += symbol : string | ||
>str : string | ||
>symbol : symbol | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Fix #19666 | ||
|
||
let symbol!: symbol; | ||
let str = "hello "; | ||
|
||
const templateStr = `hello ${symbol}`; | ||
const appendStr = "hello " + symbol; | ||
str += symbol; |