There is a type mismatch between the following interface and the actual runtime data that are string | boolean | number | null | undefined.
export interface ConfigValues {
[key: string]: string;
}
Boolean values from templates.json flow through
const evaluatedValues = context.getEvaluatedValues();
configStore.setSelections(config.id, validSelections);
configStore.setEvaluatedValues(config.id, removeEmpty(evaluatedValues));
where getEvaluatedValues returns { [key: string]: Literal | null | undefined } and setEvaluatedValues(configId: string, evaluatedValues: ConfigValues). The type mismatch goes unnoticed because removeEmpty returns any-typed objects, which is effectively assignable to a string. But booleans remain pure booleans, not "false" and "true".
Similarly
getConfigSelections(configId: string | undefined): any {
const config = this.getById(configId);
return config?.selections;
}
getConfigEvaluatedValues(configId: string | undefined): any {
const config = this.getById(configId);
return config?.evaluatedValues;
}
return any and allow the runtime boolean values to pass through without TS complaining.
But the following tests would fail:
it("Converts string 'false' selection to boolean false via context", () => {
const selections = {
"Buildings.Templates.AirHandlersFans.VAVMultiZone.have_senPreBui-have_senPreBui":
"false", // <--- ConfigValues MUST be strings: false yields type error
};
const config = addNewConfig(
"Config with false boolean selection",
mzTemplate,
createSelections(selections),
);
const context = new ConfigContext(
mzTemplate as TemplateInterface,
config as ConfigInterface,
allOptions,
config.selections as ConfigValues,
);
const value = resolveToValue("have_senPreBui", context);
expect(value).toBe(false);
});
it("Converts string 'true' selection to boolean true via context", () => {
const selections = {
"Buildings.Templates.AirHandlersFans.VAVMultiZone.have_senPreBui-have_senPreBui":
"true", // <--- ConfigValues MUST be strings: true yields type error
};
const config = addNewConfig(
"Config with true boolean selection",
mzTemplate,
createSelections(selections),
);
const context = new ConfigContext(
mzTemplate as TemplateInterface,
config as ConfigInterface,
allOptions,
config.selections as ConfigValues,
);
const value = resolveToValue("have_senPreBui", context);
expect(value).toBe(true);
});
This issue is to fix the incorrect type for ConfigValues to match what it actually stores.
And ideally fix removeEmpty getConfigSelections getConfigEvaluatedValues to preserve proper typing instead of returning any.
There is a type mismatch between the following interface and the actual runtime data that are
string | boolean | number | null | undefined.Boolean values from
templates.jsonflow throughwhere
getEvaluatedValuesreturns{ [key: string]: Literal | null | undefined }andsetEvaluatedValues(configId: string, evaluatedValues: ConfigValues). The type mismatch goes unnoticed becauseremoveEmptyreturnsany-typed objects, which is effectively assignable to a string. But booleans remain pure booleans, not"false"and"true".Similarly
return any and allow the runtime boolean values to pass through without TS complaining.
But the following tests would fail:
This issue is to fix the incorrect type for
ConfigValuesto match what it actually stores.And ideally fix
removeEmptygetConfigSelectionsgetConfigEvaluatedValuesto preserve proper typing instead of returningany.