diff --git a/Models/ThemeConfig/Conversion/Conversion.ts b/Models/ThemeConfig/Conversion/Conversion.ts index 91a89a545..d2a8184e6 100644 --- a/Models/ThemeConfig/Conversion/Conversion.ts +++ b/Models/ThemeConfig/Conversion/Conversion.ts @@ -72,6 +72,7 @@ export abstract class DesugaringStep extends Conversion {} class Pipe extends Conversion { private readonly _step0: Conversion private readonly _step1: Conversion + constructor(step0: Conversion, step1: Conversion) { super("Merges two steps with different types", [], `Pipe(${step0.name}, ${step1.name})`) this._step0 = step0 @@ -92,9 +93,9 @@ class Pipe extends Conversion { } const r = this._step1.convert(result, context) - errors.push(...r.errors) - information.push(...r.information) - warnings.push(...r.warnings) + Utils.PushList(errors, r.errors) + Utils.PushList(warnings, r.warnings) + Utils.PushList(information, r.information) return { result: r.result, errors, @@ -106,6 +107,7 @@ class Pipe extends Conversion { class Pure extends Conversion { private readonly _f: (t: TIn) => TOut + constructor(f: (t: TIn) => TOut) { super("Wrapper around a pure function", [], "Pure") this._f = f @@ -145,9 +147,9 @@ export class Each extends Conversion { const result: Y[] = [] for (let i = 0; i < values.length; i++) { const r = step.convert(values[i], context + "[" + i + "]") - information.push(...r.information) - warnings.push(...r.warnings) - errors.push(...r.errors) + Utils.PushList(information, r.information) + Utils.PushList(warnings, r.warnings) + Utils.PushList(errors, r.errors) result.push(r.result) } return { diff --git a/Utils.ts b/Utils.ts index 6fae645c5..7371308c3 100644 --- a/Utils.ts +++ b/Utils.ts @@ -456,6 +456,13 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be console.log("Added custom css file ", location) } + public static PushList(target: T[], source?: T[]) { + if (source === undefined) { + return + } + target.push(...source) + } + /** * Copies all key-value pairs of the source into the target. This will change the target * If the key starts with a '+', the values of the list will be appended to the target instead of overwritten