diff --git a/client/src/data/template.ts b/client/src/data/template.ts index d445b573..1ae39bd5 100644 --- a/client/src/data/template.ts +++ b/client/src/data/template.ts @@ -27,9 +27,9 @@ export interface OptionInterface { * Dialog(enable=...) annotation or dead end) disables the whole subtree of * an instance of this option. */ enable?: any; // { modelicaPath: string; expression: string }; - modifiers: any; - choiceModifiers?: { [key: string]: Modifiers }; - treeList: string[]; + modifiers?: any; + choiceModifiers?: { [key: string]: Modifiers | undefined }; + treeList?: string[]; definition: boolean; shortExclType: boolean; // Short class definition excluding `type` definition replaceable: boolean; diff --git a/client/src/interpreter/interpreter.ts b/client/src/interpreter/interpreter.ts index e2045aea..1ff90e36 100644 --- a/client/src/interpreter/interpreter.ts +++ b/client/src/interpreter/interpreter.ts @@ -32,7 +32,7 @@ export const constructSelectionPath = ( }; interface Modifier { - expression: Expression; + expression?: Expression | string; final: boolean; fromClassDefinition: boolean; redeclare?: string; // the redeclared type path, undefined if not a redeclare @@ -660,7 +660,7 @@ export const evaluate = ( const addToModObject = ( newMods: { [key: string]: { - expression: Expression; + expression?: Expression | string; final: boolean; redeclare?: string; recordBinding?: boolean; @@ -727,7 +727,7 @@ const getReplaceableType = ( option: OptionInterface, mods: { [key: string]: { - expression: Expression; + expression?: Expression | string; final: boolean; redeclare?: string; }; @@ -808,7 +808,7 @@ const buildModsHelper = ( const childOptions = option.options; const optionsWithModsList: string[] = - "treeList" in option && option.treeList.length > 0 + option.treeList && option.treeList.length > 0 ? option.treeList : [option.modelicaPath]; diff --git a/client/src/utils/modifier-helpers.ts b/client/src/utils/modifier-helpers.ts index 74d18239..550df465 100644 --- a/client/src/utils/modifier-helpers.ts +++ b/client/src/utils/modifier-helpers.ts @@ -13,7 +13,11 @@ export interface ConfigValues { } export type Modifiers = { - [key: string]: { expression: Expression; final: boolean; redeclare?: string }; + [key: string]: { + expression?: Expression | string; + final: boolean; + redeclare?: string; + }; }; function addToModObject( @@ -289,10 +293,10 @@ export function getUpdatedModifiers( const instancePath = key.split("-")[1]?.split(".").slice(0, -1).join(".") || ""; const option = allOptions[modelicaPath] as OptionInterface; - let choiceModifiers = {}; + let choiceModifiers: Modifiers = {}; if (option?.choiceModifiers) { - choiceModifiers = option?.choiceModifiers[value]; + choiceModifiers = option?.choiceModifiers[value] || {}; // take modifiers and change to instace keys, instancePath above and add to updatedModifiers as the last item. }