Skip to content

Commit c7d3c02

Browse files
committed
Numeric literals can be used as type
1 parent 34b2509 commit c7d3c02

File tree

5 files changed

+117
-0
lines changed

5 files changed

+117
-0
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ repository:
725725
patterns:
726726
- include: '#comment'
727727
- include: '#string'
728+
- include: '#numeric-literal'
728729
- include: '#type-primitive'
729730
- include: '#type-builtin-literals'
730731
- include: '#typeof-operator'

TypeScript.tmLanguage

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,6 +2332,10 @@
23322332
<key>include</key>
23332333
<string>#string</string>
23342334
</dict>
2335+
<dict>
2336+
<key>include</key>
2337+
<string>#numeric-literal</string>
2338+
</dict>
23352339
<dict>
23362340
<key>include</key>
23372341
<string>#type-primitive</string>

TypeScriptReact.tmLanguage

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,6 +2336,10 @@
23362336
<key>include</key>
23372337
<string>#string</string>
23382338
</dict>
2339+
<dict>
2340+
<key>include</key>
2341+
<string>#numeric-literal</string>
2342+
</dict>
23392343
<dict>
23402344
<key>include</key>
23412345
<string>#type-primitive</string>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
original file
2+
-----------------------------------
3+
let a: 1 | 3 | 5 | 7 | 9;
4+
type a = 1 | 3 | 5 | 7 | 9;
5+
-----------------------------------
6+
7+
Grammar: TypeScript.tmLanguage
8+
-----------------------------------
9+
>let a: 1 | 3 | 5 | 7 | 9;
10+
^^^
11+
source.ts meta.var.expr.ts storage.type.ts
12+
^
13+
source.ts meta.var.expr.ts
14+
^
15+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts variable.other.readwrite.ts
16+
^
17+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
18+
^
19+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
20+
^
21+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts constant.numeric.decimal.ts
22+
^
23+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
24+
^
25+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts keyword.operator.type.ts
26+
^
27+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
28+
^
29+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts constant.numeric.decimal.ts
30+
^
31+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
32+
^
33+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts keyword.operator.type.ts
34+
^
35+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
36+
^
37+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts constant.numeric.decimal.ts
38+
^
39+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
40+
^
41+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts keyword.operator.type.ts
42+
^
43+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
44+
^
45+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts constant.numeric.decimal.ts
46+
^
47+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
48+
^
49+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts keyword.operator.type.ts
50+
^
51+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
52+
^
53+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts constant.numeric.decimal.ts
54+
^
55+
source.ts punctuation.terminator.statement.ts
56+
^^
57+
source.ts
58+
>type a = 1 | 3 | 5 | 7 | 9;
59+
^^^^
60+
source.ts meta.type.declaration.ts storage.type.type.ts
61+
^
62+
source.ts meta.type.declaration.ts
63+
^
64+
source.ts meta.type.declaration.ts entity.name.type.ts
65+
^
66+
source.ts meta.type.declaration.ts
67+
^
68+
source.ts meta.type.declaration.ts keyword.operator.assignment.ts
69+
^
70+
source.ts meta.type.declaration.ts
71+
^
72+
source.ts meta.type.declaration.ts constant.numeric.decimal.ts
73+
^
74+
source.ts meta.type.declaration.ts
75+
^
76+
source.ts meta.type.declaration.ts keyword.operator.type.ts
77+
^
78+
source.ts meta.type.declaration.ts
79+
^
80+
source.ts meta.type.declaration.ts constant.numeric.decimal.ts
81+
^
82+
source.ts meta.type.declaration.ts
83+
^
84+
source.ts meta.type.declaration.ts keyword.operator.type.ts
85+
^
86+
source.ts meta.type.declaration.ts
87+
^
88+
source.ts meta.type.declaration.ts constant.numeric.decimal.ts
89+
^
90+
source.ts meta.type.declaration.ts
91+
^
92+
source.ts meta.type.declaration.ts keyword.operator.type.ts
93+
^
94+
source.ts meta.type.declaration.ts
95+
^
96+
source.ts meta.type.declaration.ts constant.numeric.decimal.ts
97+
^
98+
source.ts meta.type.declaration.ts
99+
^
100+
source.ts meta.type.declaration.ts keyword.operator.type.ts
101+
^
102+
source.ts meta.type.declaration.ts
103+
^
104+
source.ts meta.type.declaration.ts constant.numeric.decimal.ts
105+
^
106+
source.ts punctuation.terminator.statement.ts

tests/cases/numericAsType.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let a: 1 | 3 | 5 | 7 | 9;
2+
type a = 1 | 3 | 5 | 7 | 9;

0 commit comments

Comments
 (0)