fix(compiler): Update types for TypeScript nullability support
This commit is contained in:
@ -28,8 +28,11 @@ export class MockDirectiveResolver extends DirectiveResolver {
|
||||
|
||||
private _clearCacheFor(component: Type<any>) { this._compiler.clearCacheFor(component); }
|
||||
|
||||
resolve(type: Type<any>, throwIfNotFound = true): Directive {
|
||||
let metadata = this._directives.get(type);
|
||||
resolve(type: Type<any>): Directive;
|
||||
resolve(type: Type<any>, throwIfNotFound: true): Directive;
|
||||
resolve(type: Type<any>, throwIfNotFound: boolean): Directive|null;
|
||||
resolve(type: Type<any>, throwIfNotFound = true): Directive|null {
|
||||
let metadata = this._directives.get(type) || null;
|
||||
if (!metadata) {
|
||||
metadata = super.resolve(type, throwIfNotFound);
|
||||
}
|
||||
@ -53,17 +56,13 @@ export class MockDirectiveResolver extends DirectiveResolver {
|
||||
viewProviders = originalViewProviders.concat(viewProviderOverrides);
|
||||
}
|
||||
|
||||
let view = this._views.get(type);
|
||||
if (!view) {
|
||||
view = <any>metadata;
|
||||
}
|
||||
|
||||
let view = this._views.get(type) || metadata;
|
||||
let animations = view.animations;
|
||||
let templateUrl = view.templateUrl;
|
||||
let templateUrl: string|undefined = view.templateUrl;
|
||||
|
||||
let inlineTemplate = this._inlineTemplates.get(type);
|
||||
if (inlineTemplate != null) {
|
||||
templateUrl = null;
|
||||
if (inlineTemplate) {
|
||||
templateUrl = undefined;
|
||||
} else {
|
||||
inlineTemplate = view.template;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ export class MockNgModuleResolver extends NgModuleResolver {
|
||||
* `NgModuleResolver`, see `setNgModule`.
|
||||
*/
|
||||
resolve(type: Type<any>, throwIfNotFound = true): NgModule {
|
||||
return this._ngModules.get(type) || super.resolve(type, throwIfNotFound);
|
||||
return this._ngModules.get(type) || super.resolve(type, throwIfNotFound) !;
|
||||
}
|
||||
|
||||
private get _compiler(): Compiler { return this._injector.get(Compiler); }
|
||||
|
@ -36,7 +36,7 @@ export class MockPipeResolver extends PipeResolver {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): Pipe {
|
||||
let metadata = this._pipes.get(type);
|
||||
if (!metadata) {
|
||||
metadata = super.resolve(type, throwIfNotFound);
|
||||
metadata = super.resolve(type, throwIfNotFound) !;
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ export class MockResourceLoader extends ResourceLoader {
|
||||
}
|
||||
|
||||
do {
|
||||
this._processRequest(this._requests.shift());
|
||||
this._processRequest(this._requests.shift() !);
|
||||
} while (this._requests.length > 0);
|
||||
|
||||
this.verifyNoOutstandingExpectations();
|
||||
@ -110,7 +110,7 @@ class _PendingRequest {
|
||||
});
|
||||
}
|
||||
|
||||
complete(response: string) {
|
||||
complete(response: string|null) {
|
||||
if (response == null) {
|
||||
this.reject(`Failed to load ${this.url}`);
|
||||
} else {
|
||||
|
@ -58,6 +58,6 @@ export class MockSchemaRegistry implements ElementSchemaRegistry {
|
||||
normalizeAnimationStyleProperty(propName: string): string { return propName; }
|
||||
normalizeAnimationStyleValue(camelCaseProp: string, userProvidedProp: string, val: string|number):
|
||||
{error: string, value: string} {
|
||||
return {error: null, value: val.toString()};
|
||||
return {error: null !, value: val.toString()};
|
||||
}
|
||||
}
|
||||
|
@ -81,12 +81,12 @@ export class TestingCompilerImpl implements TestingCompiler {
|
||||
overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): void {
|
||||
const oldMetadata = this._directiveResolver.resolve(directive, false);
|
||||
this._directiveResolver.setDirective(
|
||||
directive, this._overrider.overrideMetadata(Directive, oldMetadata, override));
|
||||
directive, this._overrider.overrideMetadata(Directive, oldMetadata !, override));
|
||||
}
|
||||
overrideComponent(component: Type<any>, override: MetadataOverride<Component>): void {
|
||||
const oldMetadata = this._directiveResolver.resolve(component, false);
|
||||
this._directiveResolver.setDirective(
|
||||
component, this._overrider.overrideMetadata(Component, oldMetadata, override));
|
||||
component, this._overrider.overrideMetadata(Component, oldMetadata !, override));
|
||||
}
|
||||
overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): void {
|
||||
const oldMetadata = this._pipeResolver.resolve(pipe, false);
|
||||
|
Reference in New Issue
Block a user