diff --git a/packages/angular_devkit/core/src/json/schema/registry.ts b/packages/angular_devkit/core/src/json/schema/registry.ts index 1b4bd474373a..4e7c6a9e3e17 100644 --- a/packages/angular_devkit/core/src/json/schema/registry.ts +++ b/packages/angular_devkit/core/src/json/schema/registry.ts @@ -558,7 +558,7 @@ export class CoreSchemaRegistry implements SchemaRegistry { CoreSchemaRegistry._set( data, pathFragments, - answers[path] as {}, + answers[path], null, undefined, true, @@ -567,51 +567,22 @@ export class CoreSchemaRegistry implements SchemaRegistry { } private static _set( - // tslint:disable-next-line:no-any + // tslint:disable-next-line: no-any data: any, fragments: string[], - value: {}, - // tslint:disable-next-line:no-any - parent: any | null = null, + value: unknown, + parent: Record | null = null, parentProperty?: string, force?: boolean, ): void { - for (let i = 0; i < fragments.length; i++) { - const f = fragments[i]; - - if (f[0] == 'i') { - if (!Array.isArray(data)) { - return; - } - - for (let j = 0; j < data.length; j++) { - CoreSchemaRegistry._set(data[j], fragments.slice(i + 1), value, data, '' + j); - } - - return; - } - - if (f.startsWith('key')) { - if (typeof data !== 'object') { - return; - } - - for (const property in data) { - CoreSchemaRegistry._set(data[property], fragments.slice(i + 1), value, data, property); - } - - return; - } - - - // We know we need an object because the fragment is a property key. + for (const fragment of fragments) { if (!data && parent !== null && parentProperty) { data = parent[parentProperty] = {}; } - parent = data; - parentProperty = f; - data = data[f]; + parent = data; + parentProperty = fragment; + data = data[fragment]; } if (parent && parentProperty && (force || parent[parentProperty] === undefined)) {