fix: Update types for TypeScript nullability support in examples

This commit is contained in:
Miško Hevery 2017-03-24 09:57:05 -07:00 committed by Hans
parent 14669f20bf
commit 6f5fccfeb7
6 changed files with 10 additions and 9 deletions

View File

@ -57,13 +57,13 @@ class NgIfElse {
` `
}) })
class NgIfThenElse implements OnInit { class NgIfThenElse implements OnInit {
thenBlock: TemplateRef<any> = null; thenBlock: TemplateRef<any>|null = null;
show: boolean = true; show: boolean = true;
@ViewChild('primaryBlock') @ViewChild('primaryBlock')
primaryBlock: TemplateRef<any> = null; primaryBlock: TemplateRef<any>|null = null;
@ViewChild('secondaryBlock') @ViewChild('secondaryBlock')
secondaryBlock: TemplateRef<any> = null; secondaryBlock: TemplateRef<any>|null = null;
switchPrimary() { switchPrimary() {
this.thenBlock = this.thenBlock === this.primaryBlock ? this.secondaryBlock : this.primaryBlock; this.thenBlock = this.thenBlock === this.primaryBlock ? this.secondaryBlock : this.primaryBlock;

View File

@ -20,10 +20,10 @@ import {Subscriber} from 'rxjs/Subscriber';
</div>` </div>`
}) })
export class AsyncPromisePipeComponent { export class AsyncPromisePipeComponent {
greeting: Promise<string> = null; greeting: Promise<string>|null = null;
arrived: boolean = false; arrived: boolean = false;
private resolve: Function = null; private resolve: Function|null = null;
constructor() { this.reset(); } constructor() { this.reset(); }
@ -36,7 +36,7 @@ export class AsyncPromisePipeComponent {
if (this.arrived) { if (this.arrived) {
this.reset(); this.reset();
} else { } else {
this.resolve('hi there!'); this.resolve !('hi there!');
this.arrived = true; this.arrived = true;
} }
} }

View File

@ -8,7 +8,7 @@
import {DebugElement} from '@angular/core'; import {DebugElement} from '@angular/core';
let debugElement: DebugElement; let debugElement: DebugElement = undefined !;
let predicate: any; let predicate: any;
// #docregion scope_all // #docregion scope_all

View File

@ -171,7 +171,7 @@ export function main() {
declarations: [App, ParentCmp, ChildDirective], declarations: [App, ParentCmp, ChildDirective],
}); });
let cmp: ComponentFixture<App>; let cmp: ComponentFixture<App> = undefined !;
expect(() => cmp = TestBed.createComponent(App)).not.toThrow(); expect(() => cmp = TestBed.createComponent(App)).not.toThrow();
expect(cmp.debugElement.children[0].children[0].injector.get(ChildDirective).logs).toEqual([ expect(cmp.debugElement.children[0].children[0].injector.get(ChildDirective).logs).toEqual([

View File

@ -9,7 +9,7 @@
import {DebugElement} from '@angular/core'; import {DebugElement} from '@angular/core';
import {By} from '@angular/platform-browser'; import {By} from '@angular/platform-browser';
let debugElement: DebugElement; let debugElement: DebugElement = undefined !;
class MyDirective {} class MyDirective {}
// #docregion by_all // #docregion by_all

View File

@ -5,6 +5,7 @@
"stripInternal": true, "stripInternal": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"noImplicitAny": true, "noImplicitAny": true,
"strictNullChecks": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"module": "commonjs", "module": "commonjs",
"moduleResolution": "node", "moduleResolution": "node",