Skip to content

Commit 5d57ea4

Browse files
Support typescript return type of function type (#3069)
Fixes #3065 Note that I on purpose have set the domain the same as the content range. Take this example: `const foo: () => number;` We already have a type scope with content range `() => number`. If we set that as the domain for `number` it would probably be surprising if you are inside the parameters in want to target the type. @pokey Any thoughts on this?
1 parent 4fe0d65 commit 5d57ea4

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const foo: () => number;
2+
---
3+
4+
[#1 Content] = 0:11-0:23
5+
>------------<
6+
0| const foo: () => number;
7+
8+
[#1 Removal] = 0:9-0:23
9+
>--------------<
10+
0| const foo: () => number;
11+
12+
[#1 Leading delimiter] = 0:10-0:11
13+
>-<
14+
0| const foo: () => number;
15+
16+
[#1 Domain] = 0:0-0:24
17+
>------------------------<
18+
0| const foo: () => number;
19+
20+
[#1 Insertion delimiter] = " "
21+
22+
23+
[#2 Content] =
24+
[#2 Domain] = 0:17-0:23
25+
>------<
26+
0| const foo: () => number;
27+
28+
[#2 Removal] = 0:13-0:23
29+
>----------<
30+
0| const foo: () => number;
31+
32+
[#2 Leading delimiter] = 0:13-0:17
33+
>----<
34+
0| const foo: () => number;
35+
36+
[#2 Insertion delimiter] = " "

queries/typescript.core.scm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,14 @@
288288
)
289289
) @_.domain
290290

291+
;;!! foo() => string;
292+
;;! ^^^^^^
293+
(_
294+
parameters: (_) @_.leading.endOf
295+
"=>"
296+
return_type: (_) @type
297+
)
298+
291299
;;!! new Aaa<Bbb>()
292300
;;! ^^^^^^^^
293301
(new_expression

0 commit comments

Comments
 (0)