File tree Expand file tree Collapse file tree 4 files changed +22
-11
lines changed
packages/cursorless-engine/src Expand file tree Collapse file tree 4 files changed +22
-11
lines changed Original file line number Diff line number Diff line change 1
1
import { mapValues } from "lodash" ;
2
2
import {
3
+ PartialSpokenFormMapKeys ,
3
4
SpokenFormMap ,
4
5
SpokenFormMapEntry ,
5
6
SpokenFormMapKeyTypes ,
@@ -153,9 +154,11 @@ export interface DefaultSpokenFormMapEntry {
153
154
}
154
155
155
156
export type DefaultSpokenFormMap = {
156
- readonly [ K in keyof SpokenFormMapKeyTypes ] : Readonly <
157
- Record < SpokenFormMapKeyTypes [ K ] , DefaultSpokenFormMapEntry >
158
- > ;
157
+ readonly [ K in keyof SpokenFormMapKeyTypes ] : K extends PartialSpokenFormMapKeys
158
+ ? Readonly <
159
+ Partial < Record < SpokenFormMapKeyTypes [ K ] , DefaultSpokenFormMapEntry > >
160
+ >
161
+ : Record < SpokenFormMapKeyTypes [ K ] , DefaultSpokenFormMapEntry > ;
159
162
} ;
160
163
161
164
// FIXME: Don't cast here; need to make our own mapValues with stronger typing
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ export interface SpokenFormMapKeyTypes {
37
37
38
38
export type SpokenFormType = keyof SpokenFormMapKeyTypes ;
39
39
40
+ export type PartialSpokenFormMapKeys = "customRegex" ;
41
+
40
42
export interface SpokenFormMapEntry {
41
43
spokenForms : string [ ] ;
42
44
isCustom : boolean ;
@@ -46,7 +48,7 @@ export interface SpokenFormMapEntry {
46
48
}
47
49
48
50
export type SpokenFormMap = {
49
- readonly [ K in keyof SpokenFormMapKeyTypes ] : Readonly <
50
- Record < SpokenFormMapKeyTypes [ K ] , SpokenFormMapEntry >
51
- > ;
51
+ readonly [ K in keyof SpokenFormMapKeyTypes ] : K extends PartialSpokenFormMapKeys
52
+ ? Readonly < Partial < Record < SpokenFormMapKeyTypes [ K ] , SpokenFormMapEntry > > >
53
+ : Readonly < Record < SpokenFormMapKeyTypes [ K ] , SpokenFormMapEntry > > ;
52
54
} ;
Original file line number Diff line number Diff line change 1
1
import {
2
+ PartialSpokenFormMapKeys ,
2
3
SpokenFormMap ,
3
4
SpokenFormMapEntry ,
4
5
SpokenFormMapKeyTypes ,
5
6
SpokenFormType ,
6
7
} from "../SpokenFormMap" ;
7
8
8
9
export type GeneratorSpokenFormMap = {
9
- readonly [ K in keyof SpokenFormMapKeyTypes ] : Record <
10
- SpokenFormMapKeyTypes [ K ] ,
11
- SingleTermSpokenForm
12
- > ;
10
+ readonly [ K in keyof SpokenFormMapKeyTypes ] : K extends PartialSpokenFormMapKeys
11
+ ? Partial < Record < SpokenFormMapKeyTypes [ K ] , SingleTermSpokenForm > >
12
+ : Record < SpokenFormMapKeyTypes [ K ] , SingleTermSpokenForm > ;
13
13
} ;
14
14
15
15
export interface SingleTermSpokenForm {
Original file line number Diff line number Diff line change @@ -232,7 +232,13 @@ export class PrimitiveTargetSpokenFormGenerator {
232
232
return (
233
233
this . spokenFormMap . customRegex [ scopeType . regex ] ?? {
234
234
type : "singleTerm" ,
235
- spokenForms : [ ] ,
235
+ spokenForms : {
236
+ spokenForms : [ ] ,
237
+ isCustom : true ,
238
+ defaultSpokenForms : [ ] ,
239
+ requiresTalonUpdate : false ,
240
+ isSecret : false ,
241
+ } ,
236
242
spokenFormType : "customRegex" ,
237
243
id : scopeType . regex ,
238
244
}
You can’t perform that action at this time.
0 commit comments