Skip to content

Commit 2c51b77

Browse files
committed
Add test of the trivia case
1 parent fc6f627 commit 2c51b77

5 files changed

+153
-75
lines changed

tests/baselines/reference/templateLiteralTypesPatterns.errors.txt

+54-34
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,46 @@ tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(64,9): err
1515
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(65,9): error TS2345: Argument of type '"1_000"' is not assignable to parameter of type '`${number}`'.
1616
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(68,9): error TS2345: Argument of type '"a10"' is not assignable to parameter of type '`${number}`'.
1717
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(69,9): error TS2345: Argument of type '"10a"' is not assignable to parameter of type '`${number}`'.
18-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(81,9): error TS2345: Argument of type '"1e21"' is not assignable to parameter of type '`${bigint}`'.
19-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(82,9): error TS2345: Argument of type '"1E21"' is not assignable to parameter of type '`${bigint}`'.
20-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(83,9): error TS2345: Argument of type '"1e-21"' is not assignable to parameter of type '`${bigint}`'.
21-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(84,9): error TS2345: Argument of type '"1E-21"' is not assignable to parameter of type '`${bigint}`'.
22-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(87,9): error TS2345: Argument of type '"1.0"' is not assignable to parameter of type '`${bigint}`'.
23-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(88,9): error TS2345: Argument of type '"1.1"' is not assignable to parameter of type '`${bigint}`'.
24-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(89,9): error TS2345: Argument of type '"-1.1"' is not assignable to parameter of type '`${bigint}`'.
25-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(90,9): error TS2345: Argument of type '"-1.1e-10"' is not assignable to parameter of type '`${bigint}`'.
26-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(91,9): error TS2345: Argument of type '"-1.1E-10"' is not assignable to parameter of type '`${bigint}`'.
27-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(92,9): error TS2345: Argument of type '"1.1e-10"' is not assignable to parameter of type '`${bigint}`'.
28-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(95,9): error TS2345: Argument of type '"?"' is not assignable to parameter of type '`${bigint}`'.
29-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(96,9): error TS2345: Argument of type '"NaN"' is not assignable to parameter of type '`${bigint}`'.
30-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(97,9): error TS2345: Argument of type '"Infinity"' is not assignable to parameter of type '`${bigint}`'.
31-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(98,9): error TS2345: Argument of type '"+Infinity"' is not assignable to parameter of type '`${bigint}`'.
32-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(99,9): error TS2345: Argument of type '"-Infinity"' is not assignable to parameter of type '`${bigint}`'.
33-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(100,9): error TS2345: Argument of type '"1_000"' is not assignable to parameter of type '`${bigint}`'.
34-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(103,9): error TS2345: Argument of type '"a10n"' is not assignable to parameter of type '`${bigint}`'.
35-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(104,9): error TS2345: Argument of type '"10an"' is not assignable to parameter of type '`${bigint}`'.
36-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(107,9): error TS2345: Argument of type '"1n"' is not assignable to parameter of type '`${bigint}`'.
37-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(108,9): error TS2345: Argument of type '"-1n"' is not assignable to parameter of type '`${bigint}`'.
38-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(109,9): error TS2345: Argument of type '"0n"' is not assignable to parameter of type '`${bigint}`'.
39-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(110,9): error TS2345: Argument of type '"0b1n"' is not assignable to parameter of type '`${bigint}`'.
40-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(111,9): error TS2345: Argument of type '"0x1n"' is not assignable to parameter of type '`${bigint}`'.
41-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(112,9): error TS2345: Argument of type '"0o1n"' is not assignable to parameter of type '`${bigint}`'.
42-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(113,9): error TS2345: Argument of type '"1e21n"' is not assignable to parameter of type '`${bigint}`'.
43-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(114,9): error TS2345: Argument of type '"1E21n"' is not assignable to parameter of type '`${bigint}`'.
44-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(115,9): error TS2345: Argument of type '"1e-21n"' is not assignable to parameter of type '`${bigint}`'.
45-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(116,9): error TS2345: Argument of type '"1E-21n"' is not assignable to parameter of type '`${bigint}`'.
46-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(117,9): error TS2345: Argument of type '"1.1n"' is not assignable to parameter of type '`${bigint}`'.
47-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(118,9): error TS2345: Argument of type '"-1.1n"' is not assignable to parameter of type '`${bigint}`'.
48-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(119,9): error TS2345: Argument of type '"-1.1e-10n"' is not assignable to parameter of type '`${bigint}`'.
49-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(120,9): error TS2345: Argument of type '"-1.1E-10n"' is not assignable to parameter of type '`${bigint}`'.
50-
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(121,9): error TS2345: Argument of type '"1.1e-10n"' is not assignable to parameter of type '`${bigint}`'.
18+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(72,9): error TS2345: Argument of type '"- 1"' is not assignable to parameter of type '`${number}`'.
19+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(73,9): error TS2345: Argument of type '"-/**/1"' is not assignable to parameter of type '`${number}`'.
20+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(85,9): error TS2345: Argument of type '"1e21"' is not assignable to parameter of type '`${bigint}`'.
21+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(86,9): error TS2345: Argument of type '"1E21"' is not assignable to parameter of type '`${bigint}`'.
22+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(87,9): error TS2345: Argument of type '"1e-21"' is not assignable to parameter of type '`${bigint}`'.
23+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(88,9): error TS2345: Argument of type '"1E-21"' is not assignable to parameter of type '`${bigint}`'.
24+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(91,9): error TS2345: Argument of type '"1.0"' is not assignable to parameter of type '`${bigint}`'.
25+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(92,9): error TS2345: Argument of type '"1.1"' is not assignable to parameter of type '`${bigint}`'.
26+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(93,9): error TS2345: Argument of type '"-1.1"' is not assignable to parameter of type '`${bigint}`'.
27+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(94,9): error TS2345: Argument of type '"-1.1e-10"' is not assignable to parameter of type '`${bigint}`'.
28+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(95,9): error TS2345: Argument of type '"-1.1E-10"' is not assignable to parameter of type '`${bigint}`'.
29+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(96,9): error TS2345: Argument of type '"1.1e-10"' is not assignable to parameter of type '`${bigint}`'.
30+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(99,9): error TS2345: Argument of type '"?"' is not assignable to parameter of type '`${bigint}`'.
31+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(100,9): error TS2345: Argument of type '"NaN"' is not assignable to parameter of type '`${bigint}`'.
32+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(101,9): error TS2345: Argument of type '"Infinity"' is not assignable to parameter of type '`${bigint}`'.
33+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(102,9): error TS2345: Argument of type '"+Infinity"' is not assignable to parameter of type '`${bigint}`'.
34+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(103,9): error TS2345: Argument of type '"-Infinity"' is not assignable to parameter of type '`${bigint}`'.
35+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(104,9): error TS2345: Argument of type '"1_000"' is not assignable to parameter of type '`${bigint}`'.
36+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(107,9): error TS2345: Argument of type '"- 1"' is not assignable to parameter of type '`${bigint}`'.
37+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(108,9): error TS2345: Argument of type '"-/**/1"' is not assignable to parameter of type '`${bigint}`'.
38+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(111,9): error TS2345: Argument of type '"a10n"' is not assignable to parameter of type '`${bigint}`'.
39+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(112,9): error TS2345: Argument of type '"10an"' is not assignable to parameter of type '`${bigint}`'.
40+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(115,9): error TS2345: Argument of type '"1n"' is not assignable to parameter of type '`${bigint}`'.
41+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(116,9): error TS2345: Argument of type '"-1n"' is not assignable to parameter of type '`${bigint}`'.
42+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(117,9): error TS2345: Argument of type '"0n"' is not assignable to parameter of type '`${bigint}`'.
43+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(118,9): error TS2345: Argument of type '"0b1n"' is not assignable to parameter of type '`${bigint}`'.
44+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(119,9): error TS2345: Argument of type '"0x1n"' is not assignable to parameter of type '`${bigint}`'.
45+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(120,9): error TS2345: Argument of type '"0o1n"' is not assignable to parameter of type '`${bigint}`'.
46+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(121,9): error TS2345: Argument of type '"1e21n"' is not assignable to parameter of type '`${bigint}`'.
47+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(122,9): error TS2345: Argument of type '"1E21n"' is not assignable to parameter of type '`${bigint}`'.
48+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(123,9): error TS2345: Argument of type '"1e-21n"' is not assignable to parameter of type '`${bigint}`'.
49+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(124,9): error TS2345: Argument of type '"1E-21n"' is not assignable to parameter of type '`${bigint}`'.
50+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(125,9): error TS2345: Argument of type '"1.1n"' is not assignable to parameter of type '`${bigint}`'.
51+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(126,9): error TS2345: Argument of type '"-1.1n"' is not assignable to parameter of type '`${bigint}`'.
52+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(127,9): error TS2345: Argument of type '"-1.1e-10n"' is not assignable to parameter of type '`${bigint}`'.
53+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(128,9): error TS2345: Argument of type '"-1.1E-10n"' is not assignable to parameter of type '`${bigint}`'.
54+
tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(129,9): error TS2345: Argument of type '"1.1e-10n"' is not assignable to parameter of type '`${bigint}`'.
5155

5256

53-
==== tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts (50 errors) ====
57+
==== tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts (54 errors) ====
5458
type RequiresLeadingSlash = `/${string}`;
5559

5660
// ok
@@ -155,6 +159,14 @@ tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(121,9): er
155159
~~~~~
156160
!!! error TS2345: Argument of type '"10a"' is not assignable to parameter of type '`${number}`'.
157161

162+
// whitespace and comments aren't part of numbers
163+
numbers("- 1");
164+
~~~~~
165+
!!! error TS2345: Argument of type '"- 1"' is not assignable to parameter of type '`${number}`'.
166+
numbers("-/**/1");
167+
~~~~~~~~
168+
!!! error TS2345: Argument of type '"-/**/1"' is not assignable to parameter of type '`${number}`'.
169+
158170
declare function bigints(x: `${bigint}`): void;
159171
// the following should work
160172
bigints("1");
@@ -218,6 +230,14 @@ tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts(121,9): er
218230
~~~~~~~
219231
!!! error TS2345: Argument of type '"1_000"' is not assignable to parameter of type '`${bigint}`'.
220232

233+
// whitespace and comments aren't part of numbers
234+
bigints("- 1");
235+
~~~~~
236+
!!! error TS2345: Argument of type '"- 1"' is not assignable to parameter of type '`${bigint}`'.
237+
bigints("-/**/1");
238+
~~~~~~~~
239+
!!! error TS2345: Argument of type '"-/**/1"' is not assignable to parameter of type '`${bigint}`'.
240+
221241
// the following should be errors since they don't match the pattern
222242
bigints("a10n");
223243
~~~~~~

tests/baselines/reference/templateLiteralTypesPatterns.js

+14
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ numbers("1_000");
6969
numbers("a10");
7070
numbers("10a");
7171

72+
// whitespace and comments aren't part of numbers
73+
numbers("- 1");
74+
numbers("-/**/1");
75+
7276
declare function bigints(x: `${bigint}`): void;
7377
// the following should work
7478
bigints("1");
@@ -100,6 +104,10 @@ bigints("+Infinity");
100104
bigints("-Infinity");
101105
bigints("1_000");
102106

107+
// whitespace and comments aren't part of numbers
108+
bigints("- 1");
109+
bigints("-/**/1");
110+
103111
// the following should be errors since they don't match the pattern
104112
bigints("a10n");
105113
bigints("10an");
@@ -176,6 +184,9 @@ numbers("1_000");
176184
// the following should be errors since they don't match the pattern
177185
numbers("a10");
178186
numbers("10a");
187+
// whitespace and comments aren't part of numbers
188+
numbers("- 1");
189+
numbers("-/**/1");
179190
// the following should work
180191
bigints("1");
181192
bigints("-1");
@@ -202,6 +213,9 @@ bigints("Infinity");
202213
bigints("+Infinity");
203214
bigints("-Infinity");
204215
bigints("1_000");
216+
// whitespace and comments aren't part of numbers
217+
bigints("- 1");
218+
bigints("-/**/1");
205219
// the following should be errors since they don't match the pattern
206220
bigints("a10n");
207221
bigints("10an");

0 commit comments

Comments
 (0)