Skip to content

Commit 8e391f8

Browse files
committed
feat(@angular-devkit/core): invalid smart default sources are now returning undefined
This is a break from the previous API, but it wasnt properly defined. Smart defaults are never guaranteed to return a value anyway. The next step in cleaning up smart defaults would be to have them run _before_ validation so that smart defaults should be validated for type and optional/require.
1 parent a7e0f83 commit 8e391f8

File tree

1 file changed

+1
-10
lines changed
  • packages/angular_devkit/core/src/json/schema

1 file changed

+1
-10
lines changed

packages/angular_devkit/core/src/json/schema/registry.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,6 @@ export class CoreSchemaRegistry implements SchemaRegistry {
296296
modifying: true,
297297
async: true,
298298
compile: (schema, _parentSchema, it) => {
299-
const source = this._sourceMap.get((schema as JsonObject).$source as string);
300-
301-
if (!source) {
302-
throw new Error(`Invalid source: ${JSON.stringify(source)}.`);
303-
}
304-
305299
// We cheat, heavily.
306300
this._smartDefaultRecord.set(
307301
// tslint:disable-next-line:no-any
@@ -384,11 +378,8 @@ export class CoreSchemaRegistry implements SchemaRegistry {
384378
const fragments = JSON.parse(pointer);
385379
const source = this._sourceMap.get((schema as JsonObject).$source as string);
386380

387-
if (!source) {
388-
throw new Error('Invalid source.');
389-
}
381+
let value = source ? source(schema) : observableOf(undefined);
390382

391-
let value = source(schema);
392383
if (!isObservable(value)) {
393384
value = observableOf(value);
394385
}

0 commit comments

Comments
 (0)