Skip to content

Commit 5338500

Browse files
committed
Update symbol template test case with errors to include union types
1 parent 4e5c7be commit 5338500

File tree

5 files changed

+48
-1
lines changed

5 files changed

+48
-1
lines changed

tests/baselines/reference/noImplicitSymbolToString.errors.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
tests/cases/compiler/noImplicitSymbolToString.ts(6,30): error TS2352: Type 'symbol' cannot be converted to type 'string'.
22
tests/cases/compiler/noImplicitSymbolToString.ts(7,30): error TS2469: The '+' operator cannot be applied to type 'symbol'.
33
tests/cases/compiler/noImplicitSymbolToString.ts(8,8): error TS2469: The '+=' operator cannot be applied to type 'symbol'.
4+
tests/cases/compiler/noImplicitSymbolToString.ts(13,47): error TS2352: Type 'symbol' cannot be converted to type 'string'.
5+
tests/cases/compiler/noImplicitSymbolToString.ts(13,90): error TS2352: Type 'symbol' cannot be converted to type 'string'.
46

57

6-
==== tests/cases/compiler/noImplicitSymbolToString.ts (3 errors) ====
8+
==== tests/cases/compiler/noImplicitSymbolToString.ts (5 errors) ====
79
// Fix #19666
810

911
let symbol!: symbol;
@@ -18,4 +20,13 @@ tests/cases/compiler/noImplicitSymbolToString.ts(8,8): error TS2469: The '+=' op
1820
str += symbol;
1921
~~~~~~
2022
!!! error TS2469: The '+=' operator cannot be applied to type 'symbol'.
23+
24+
let symbolUnionNumber!: symbol | number;
25+
let symbolUnionString!: symbol | string;
26+
27+
const templateStrUnion = `union with number ${symbolUnionNumber} and union with string ${symbolUnionString}`;
28+
~~~~~~~~~~~~~~~~~
29+
!!! error TS2352: Type 'symbol' cannot be converted to type 'string'.
30+
~~~~~~~~~~~~~~~~~
31+
!!! error TS2352: Type 'symbol' cannot be converted to type 'string'.
2132

tests/baselines/reference/noImplicitSymbolToString.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ let str = "hello ";
77
const templateStr = `hello ${symbol}`;
88
const appendStr = "hello " + symbol;
99
str += symbol;
10+
11+
let symbolUnionNumber!: symbol | number;
12+
let symbolUnionString!: symbol | string;
13+
14+
const templateStrUnion = `union with number ${symbolUnionNumber} and union with string ${symbolUnionString}`;
1015

1116

1217
//// [noImplicitSymbolToString.js]
@@ -16,3 +21,6 @@ var str = "hello ";
1621
var templateStr = "hello " + symbol;
1722
var appendStr = "hello " + symbol;
1823
str += symbol;
24+
var symbolUnionNumber;
25+
var symbolUnionString;
26+
var templateStrUnion = "union with number " + symbolUnionNumber + " and union with string " + symbolUnionString;

tests/baselines/reference/noImplicitSymbolToString.symbols

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,14 @@ str += symbol;
1919
>str : Symbol(str, Decl(noImplicitSymbolToString.ts, 3, 3))
2020
>symbol : Symbol(symbol, Decl(noImplicitSymbolToString.ts, 2, 3))
2121

22+
let symbolUnionNumber!: symbol | number;
23+
>symbolUnionNumber : Symbol(symbolUnionNumber, Decl(noImplicitSymbolToString.ts, 9, 3))
24+
25+
let symbolUnionString!: symbol | string;
26+
>symbolUnionString : Symbol(symbolUnionString, Decl(noImplicitSymbolToString.ts, 10, 3))
27+
28+
const templateStrUnion = `union with number ${symbolUnionNumber} and union with string ${symbolUnionString}`;
29+
>templateStrUnion : Symbol(templateStrUnion, Decl(noImplicitSymbolToString.ts, 12, 5))
30+
>symbolUnionNumber : Symbol(symbolUnionNumber, Decl(noImplicitSymbolToString.ts, 9, 3))
31+
>symbolUnionString : Symbol(symbolUnionString, Decl(noImplicitSymbolToString.ts, 10, 3))
32+

tests/baselines/reference/noImplicitSymbolToString.types

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,15 @@ str += symbol;
2424
>str : string
2525
>symbol : symbol
2626

27+
let symbolUnionNumber!: symbol | number;
28+
>symbolUnionNumber : number | symbol
29+
30+
let symbolUnionString!: symbol | string;
31+
>symbolUnionString : string | symbol
32+
33+
const templateStrUnion = `union with number ${symbolUnionNumber} and union with string ${symbolUnionString}`;
34+
>templateStrUnion : string
35+
>`union with number ${symbolUnionNumber} and union with string ${symbolUnionString}` : string
36+
>symbolUnionNumber : number | symbol
37+
>symbolUnionString : string | symbol
38+

tests/cases/compiler/noImplicitSymbolToString.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ let str = "hello ";
66
const templateStr = `hello ${symbol}`;
77
const appendStr = "hello " + symbol;
88
str += symbol;
9+
10+
let symbolUnionNumber!: symbol | number;
11+
let symbolUnionString!: symbol | string;
12+
13+
const templateStrUnion = `union with number ${symbolUnionNumber} and union with string ${symbolUnionString}`;

0 commit comments

Comments
 (0)