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 11import { mapValues } from "lodash" ;
22import {
3+ PartialSpokenFormMapKeys ,
34 SpokenFormMap ,
45 SpokenFormMapEntry ,
56 SpokenFormMapKeyTypes ,
@@ -153,9 +154,11 @@ export interface DefaultSpokenFormMapEntry {
153154}
154155
155156export 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 > ;
159162} ;
160163
161164// 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 {
3737
3838export type SpokenFormType = keyof SpokenFormMapKeyTypes ;
3939
40+ export type PartialSpokenFormMapKeys = "customRegex" ;
41+
4042export interface SpokenFormMapEntry {
4143 spokenForms : string [ ] ;
4244 isCustom : boolean ;
@@ -46,7 +48,7 @@ export interface SpokenFormMapEntry {
4648}
4749
4850export 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 > > ;
5254} ;
Original file line number Diff line number Diff line change 11import {
2+ PartialSpokenFormMapKeys ,
23 SpokenFormMap ,
34 SpokenFormMapEntry ,
45 SpokenFormMapKeyTypes ,
56 SpokenFormType ,
67} from "../SpokenFormMap" ;
78
89export 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 > ;
1313} ;
1414
1515export interface SingleTermSpokenForm {
Original file line number Diff line number Diff line change @@ -232,7 +232,13 @@ export class PrimitiveTargetSpokenFormGenerator {
232232 return (
233233 this . spokenFormMap . customRegex [ scopeType . regex ] ?? {
234234 type : "singleTerm" ,
235- spokenForms : [ ] ,
235+ spokenForms : {
236+ spokenForms : [ ] ,
237+ isCustom : true ,
238+ defaultSpokenForms : [ ] ,
239+ requiresTalonUpdate : false ,
240+ isSecret : false ,
241+ } ,
236242 spokenFormType : "customRegex" ,
237243 id : scopeType . regex ,
238244 }
You can’t perform that action at this time.
0 commit comments