Skip to content

Commit

Permalink
feat(@angular-devkit/core): invalid smart default sources are now ret…
Browse files Browse the repository at this point in the history
…urning 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.
  • Loading branch information
hansl committed Jun 6, 2018
1 parent a7e0f83 commit 8e391f8
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions packages/angular_devkit/core/src/json/schema/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,6 @@ export class CoreSchemaRegistry implements SchemaRegistry {
modifying: true,
async: true,
compile: (schema, _parentSchema, it) => {
const source = this._sourceMap.get((schema as JsonObject).$source as string);

if (!source) {
throw new Error(`Invalid source: ${JSON.stringify(source)}.`);
}

// We cheat, heavily.
this._smartDefaultRecord.set(
// tslint:disable-next-line:no-any
Expand Down Expand Up @@ -384,11 +378,8 @@ export class CoreSchemaRegistry implements SchemaRegistry {
const fragments = JSON.parse(pointer);
const source = this._sourceMap.get((schema as JsonObject).$source as string);

if (!source) {
throw new Error('Invalid source.');
}
let value = source ? source(schema) : observableOf(undefined);

let value = source(schema);
if (!isObservable(value)) {
value = observableOf(value);
}
Expand Down

0 comments on commit 8e391f8

Please sign in to comment.