Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/src/data/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions client/src/interpreter/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -660,7 +660,7 @@ export const evaluate = (
const addToModObject = (
newMods: {
[key: string]: {
expression: Expression;
expression?: Expression | string;
final: boolean;
redeclare?: string;
recordBinding?: boolean;
Expand Down Expand Up @@ -727,7 +727,7 @@ const getReplaceableType = (
option: OptionInterface,
mods: {
[key: string]: {
expression: Expression;
expression?: Expression | string;
final: boolean;
redeclare?: string;
};
Expand Down Expand Up @@ -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];

Expand Down
10 changes: 7 additions & 3 deletions client/src/utils/modifier-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.
}

Expand Down