Skip to content

Commit 8975bb1

Browse files
committed
Fix typeof as typeof expression in type arguments
Fixes #846
1 parent a755c6b commit 8975bb1

File tree

5 files changed

+88
-3
lines changed

5 files changed

+88
-3
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ repository:
17391739
begin: '{{startOfIdentifier}}typeof{{endOfIdentifier}}'
17401740
beginCaptures:
17411741
'0': { name: keyword.operator.expression.typeof.ts }
1742-
end: (?=[,);}\]=]|$|{{endOfStatement}})
1742+
end: (?=[,);}\]=>]|$|{{endOfStatement}})
17431743
patterns:
17441744
- include: '#expression'
17451745

TypeScript.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5641,7 +5641,7 @@
56415641
</dict>
56425642
</dict>
56435643
<key>end</key>
5644-
<string>(?=[,);}\]=]|$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
5644+
<string>(?=[,);}\]=&gt;]|$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
56455645
<key>patterns</key>
56465646
<array>
56475647
<dict>

TypeScriptReact.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5587,7 +5587,7 @@
55875587
</dict>
55885588
</dict>
55895589
<key>end</key>
5590-
<string>(?=[,);}\]=]|$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
5590+
<string>(?=[,);}\]=&gt;]|$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
55915591
<key>patterns</key>
55925592
<array>
55935593
<dict>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
original file
2+
-----------------------------------
3+
function foo(): number { return 42; }
4+
let bar: ReturnType<typeof foo>;
5+
bar = 1;
6+
-----------------------------------
7+
8+
Grammar: TypeScript.tmLanguage
9+
-----------------------------------
10+
>function foo(): number { return 42; }
11+
^^^^^^^^
12+
source.ts meta.function.ts storage.type.function.ts
13+
^
14+
source.ts meta.function.ts
15+
^^^
16+
source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts
17+
^
18+
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
19+
^
20+
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
21+
^
22+
source.ts meta.function.ts meta.return.type.ts keyword.operator.type.annotation.ts
23+
^
24+
source.ts meta.function.ts meta.return.type.ts
25+
^^^^^^
26+
source.ts meta.function.ts meta.return.type.ts support.type.primitive.ts
27+
^
28+
source.ts meta.function.ts meta.return.type.ts
29+
^
30+
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
31+
^
32+
source.ts meta.function.ts meta.block.ts
33+
^^^^^^
34+
source.ts meta.function.ts meta.block.ts keyword.control.flow.ts
35+
^
36+
source.ts meta.function.ts meta.block.ts
37+
^^
38+
source.ts meta.function.ts meta.block.ts constant.numeric.decimal.ts
39+
^
40+
source.ts meta.function.ts meta.block.ts punctuation.terminator.statement.ts
41+
^
42+
source.ts meta.function.ts meta.block.ts
43+
^
44+
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
45+
>let bar: ReturnType<typeof foo>;
46+
^^^
47+
source.ts meta.var.expr.ts storage.type.ts
48+
^
49+
source.ts meta.var.expr.ts
50+
^^^
51+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts
52+
^
53+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
54+
^
55+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
56+
^^^^^^^^^^
57+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts entity.name.type.ts
58+
^
59+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts
60+
^^^^^^
61+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.type.parameters.ts keyword.operator.expression.typeof.ts
62+
^
63+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.type.parameters.ts
64+
^^^
65+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.type.parameters.ts variable.other.readwrite.ts
66+
^
67+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts
68+
^
69+
source.ts punctuation.terminator.statement.ts
70+
>bar = 1;
71+
^^^
72+
source.ts variable.other.readwrite.ts
73+
^
74+
source.ts
75+
^
76+
source.ts keyword.operator.assignment.ts
77+
^
78+
source.ts
79+
^
80+
source.ts constant.numeric.decimal.ts
81+
^
82+
source.ts punctuation.terminator.statement.ts

tests/cases/Issue846.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function foo(): number { return 42; }
2+
let bar: ReturnType<typeof foo>;
3+
bar = 1;

0 commit comments

Comments
 (0)