Skip to content

Commit 971ee29

Browse files
authored
typescript: Support "value" for type alias (#2361)
I wouldn't say I feel super strongly, but it looked like "value" to my brain so I tried to use "value" here ## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [-] I have not broken the cheatsheet
1 parent 2fb06a1 commit 971ee29

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
type Aaa = Bbb;
2+
---
3+
4+
[Content] = 0:11-0:14
5+
>---<
6+
0| type Aaa = Bbb;
7+
8+
[Removal] = 0:10-0:14
9+
>----<
10+
0| type Aaa = Bbb;
11+
12+
[Leading delimiter] = 0:10-0:11
13+
>-<
14+
0| type Aaa = Bbb;
15+
16+
[Domain] = 0:0-0:15
17+
>---------------<
18+
0| type Aaa = Bbb;
19+
20+
[Insertion delimiter] = " "
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export type Aaa = Bbb;
2+
---
3+
4+
[Content] = 0:18-0:21
5+
>---<
6+
0| export type Aaa = Bbb;
7+
8+
[Removal] = 0:17-0:21
9+
>----<
10+
0| export type Aaa = Bbb;
11+
12+
[Leading delimiter] = 0:17-0:18
13+
>-<
14+
0| export type Aaa = Bbb;
15+
16+
[Domain] = 0:0-0:22
17+
>----------------------<
18+
0| export type Aaa = Bbb;
19+
20+
[Insertion delimiter] = " "

packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ export const scopeSupportFacetInfos: Record<
376376
scopeType: "value",
377377
isIteration: true,
378378
},
379+
"value.typeAlias": {
380+
description: "Value of a type alias declaration",
381+
scopeType: "value",
382+
},
379383

380384
"type.variable": {
381385
description: "Type of variable in a variable declaration",

packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const scopeSupportFacets = [
9595
"value.resource.iteration",
9696
"value.argument.formal",
9797
"value.argument.formal.iteration",
98+
"value.typeAlias",
9899

99100
"type.variable",
100101
"type.formalParameter",

packages/common/src/scopeSupportFacets/typescript.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ export const typescriptScopeSupport: LanguageScopeSupportFacetMap = {
1919
"type.alias": supported,
2020
"name.field": supported,
2121
"value.field": supported,
22+
"value.typeAlias": supported,
2223
"type.cast": supported,
2324
};

queries/typescript.core.scm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@
8585
";"? @_.domain.end
8686
)
8787

88+
(
89+
(type_alias_declaration
90+
value: (_) @value
91+
) @_.domain
92+
(#not-parent-type? @_.domain export_statement)
93+
)
94+
(export_statement
95+
(type_alias_declaration
96+
value: (_) @value
97+
)
98+
) @_.domain
99+
88100
[
89101
(interface_declaration)
90102
(object_type)

0 commit comments

Comments
 (0)