File tree Expand file tree Collapse file tree 4 files changed +28
-12
lines changed
packages/cursorless-engine/src Expand file tree Collapse file tree 4 files changed +28
-12
lines changed Original file line number Diff line number Diff line change 11import { mapValues } from "lodash" ;
22import {
3+ PartialSpokenFormTypes ,
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 PartialSpokenFormTypes
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 @@ -58,6 +58,13 @@ export interface SpokenFormMapKeyTypes {
5858
5959export type SpokenFormType = keyof SpokenFormMapKeyTypes ;
6060
61+ /**
62+ * These are the types of spoken forms that are not total mappings, eg if you
63+ * look up a string in `spokenFormMap.customRegex`, you might get `undefined`,
64+ * even though technically the identifier type is `string`.
65+ */
66+ export type PartialSpokenFormTypes = "customRegex" ;
67+
6168export interface SpokenFormMapEntry {
6269 /**
6370 * The spoken forms for this entry. These could either be a user's custom
@@ -102,7 +109,7 @@ export interface SpokenFormMapEntry {
102109 * the value is a map of identifiers to {@link SpokenFormMapEntry}s.
103110 */
104111export type SpokenFormMap = {
105- readonly [ K in keyof SpokenFormMapKeyTypes ] : Readonly <
106- Record < SpokenFormMapKeyTypes [ K ] , SpokenFormMapEntry >
107- > ;
112+ readonly [ K in keyof SpokenFormMapKeyTypes ] : K extends PartialSpokenFormTypes
113+ ? Readonly < Partial < Record < SpokenFormMapKeyTypes [ K ] , SpokenFormMapEntry > > >
114+ : Readonly < Record < SpokenFormMapKeyTypes [ K ] , SpokenFormMapEntry > > ;
108115} ;
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 @@ -229,8 +229,14 @@ export class PrimitiveTargetSpokenFormGenerator {
229229 case "customRegex" :
230230 return (
231231 this . spokenFormMap . customRegex [ scopeType . regex ] ?? {
232- type : "singleTerm" ,
233- spokenForms : [ ] ,
232+ type : "customizable" ,
233+ spokenForms : {
234+ spokenForms : [ ] ,
235+ isCustom : true ,
236+ defaultSpokenForms : [ ] ,
237+ requiresTalonUpdate : false ,
238+ isSecret : false ,
239+ } ,
234240 spokenFormType : "customRegex" ,
235241 id : scopeType . regex ,
236242 }
You can’t perform that action at this time.
0 commit comments