fix(core): Update types for TypeScript nullability support (#15472)
This commit is contained in:

committed by
Victor Berchet

parent
331b9f6425
commit
910c0d9ee7
@ -42,15 +42,16 @@ export class ComponentFixture<T> {
|
||||
|
||||
private _isStable: boolean = true;
|
||||
private _isDestroyed: boolean = false;
|
||||
private _resolve: (result: any) => void;
|
||||
private _promise: Promise<any> = null;
|
||||
private _resolve: ((result: any) => void)|null = null;
|
||||
private _promise: Promise<any>|null = null;
|
||||
private _onUnstableSubscription: any /** TODO #9100 */ = null;
|
||||
private _onStableSubscription: any /** TODO #9100 */ = null;
|
||||
private _onMicrotaskEmptySubscription: any /** TODO #9100 */ = null;
|
||||
private _onErrorSubscription: any /** TODO #9100 */ = null;
|
||||
|
||||
constructor(
|
||||
public componentRef: ComponentRef<T>, public ngZone: NgZone, private _autoDetect: boolean) {
|
||||
public componentRef: ComponentRef<T>, public ngZone: NgZone|null,
|
||||
private _autoDetect: boolean) {
|
||||
this.changeDetectorRef = componentRef.changeDetectorRef;
|
||||
this.elementRef = componentRef.location;
|
||||
this.debugElement = <DebugElement>getDebugNode(this.elementRef.nativeElement);
|
||||
@ -59,7 +60,7 @@ export class ComponentFixture<T> {
|
||||
this.componentRef = componentRef;
|
||||
this.ngZone = ngZone;
|
||||
|
||||
if (ngZone != null) {
|
||||
if (ngZone) {
|
||||
this._onUnstableSubscription =
|
||||
ngZone.onUnstable.subscribe({next: () => { this._isStable = false; }});
|
||||
this._onMicrotaskEmptySubscription = ngZone.onMicrotaskEmpty.subscribe({
|
||||
@ -82,7 +83,7 @@ export class ComponentFixture<T> {
|
||||
scheduleMicroTask(() => {
|
||||
if (!this.ngZone.hasPendingMacrotasks) {
|
||||
if (this._promise !== null) {
|
||||
this._resolve(true);
|
||||
this._resolve !(true);
|
||||
this._resolve = null;
|
||||
this._promise = null;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ export class TestBed implements Injector {
|
||||
}
|
||||
|
||||
static overrideTemplate(component: Type<any>, template: string): typeof TestBed {
|
||||
getTestBed().overrideComponent(component, {set: {template, templateUrl: null}});
|
||||
getTestBed().overrideComponent(component, {set: {template, templateUrl: null !}});
|
||||
return TestBed;
|
||||
}
|
||||
|
||||
@ -149,9 +149,9 @@ export class TestBed implements Injector {
|
||||
|
||||
private _instantiated: boolean = false;
|
||||
|
||||
private _compiler: TestingCompiler = null;
|
||||
private _moduleRef: NgModuleRef<any> = null;
|
||||
private _moduleWithComponentFactories: ModuleWithComponentFactories<any> = null;
|
||||
private _compiler: TestingCompiler = null !;
|
||||
private _moduleRef: NgModuleRef<any> = null !;
|
||||
private _moduleWithComponentFactories: ModuleWithComponentFactories<any> = null !;
|
||||
|
||||
private _compilerOptions: CompilerOptions[] = [];
|
||||
|
||||
@ -194,19 +194,19 @@ export class TestBed implements Injector {
|
||||
*/
|
||||
resetTestEnvironment() {
|
||||
this.resetTestingModule();
|
||||
this.platform = null;
|
||||
this.ngModule = null;
|
||||
this.platform = null !;
|
||||
this.ngModule = null !;
|
||||
}
|
||||
|
||||
resetTestingModule() {
|
||||
this._compiler = null;
|
||||
this._compiler = null !;
|
||||
this._moduleOverrides = [];
|
||||
this._componentOverrides = [];
|
||||
this._directiveOverrides = [];
|
||||
this._pipeOverrides = [];
|
||||
|
||||
this._moduleRef = null;
|
||||
this._moduleWithComponentFactories = null;
|
||||
this._moduleRef = null !;
|
||||
this._moduleWithComponentFactories = null !;
|
||||
this._compilerOptions = [];
|
||||
this._providers = [];
|
||||
this._declarations = [];
|
||||
@ -223,9 +223,9 @@ export class TestBed implements Injector {
|
||||
this._activeFixtures = [];
|
||||
}
|
||||
|
||||
platform: PlatformRef = null;
|
||||
platform: PlatformRef = null !;
|
||||
|
||||
ngModule: Type<any>|Type<any>[] = null;
|
||||
ngModule: Type<any>|Type<any>[] = null !;
|
||||
|
||||
configureCompiler(config: {providers?: any[], useJit?: boolean}) {
|
||||
this._assertNotInstantiated('TestBed.configureCompiler', 'configure the compiler');
|
||||
@ -383,7 +383,7 @@ export class TestBed implements Injector {
|
||||
}
|
||||
}
|
||||
|
||||
let _testBed: TestBed = null;
|
||||
let _testBed: TestBed = null !;
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
@ -463,7 +463,7 @@ export class InjectSetupWrapper {
|
||||
*/
|
||||
export function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
|
||||
export function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;
|
||||
export function withModule(moduleDef: TestModuleMetadata, fn: Function = null): (() => any)|
|
||||
export function withModule(moduleDef: TestModuleMetadata, fn?: Function | null): (() => any)|
|
||||
InjectSetupWrapper {
|
||||
if (fn) {
|
||||
// Not using an arrow function to preserve context passed from call site
|
||||
|
@ -62,7 +62,7 @@ jsmBeforeEach(() => { testBed.resetTestingModule(); });
|
||||
|
||||
function _describe(jsmFn: Function, ...args: any[]) {
|
||||
const parentRunner = runnerStack.length === 0 ? null : runnerStack[runnerStack.length - 1];
|
||||
const runner = new BeforeEachRunner(parentRunner);
|
||||
const runner = new BeforeEachRunner(parentRunner !);
|
||||
runnerStack.push(runner);
|
||||
const suite = jsmFn(...args);
|
||||
runnerStack.pop();
|
||||
|
Reference in New Issue
Block a user