Skip to content

Commit 2bf7024

Browse files
crisbetojelbourn
authored andcommitted
feat: add support for strict null checks (#5094)
1 parent 49dfe60 commit 2bf7024

File tree

122 files changed

+764
-662
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+764
-662
lines changed

e2e/components/tabs-e2e.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe('tabs', () => {
7575
*/
7676
async function getFocusStates(elements: ElementArrayFinder) {
7777
return elements.map(async (element) => {
78-
let elementText = await element.getText();
78+
let elementText = await element!.getText();
7979
let activeText = await browser.driver.switchTo().activeElement().getText();
8080

8181
return activeText === elementText;
@@ -98,7 +98,7 @@ function getBodyActiveStates(elements: ElementArrayFinder) {
9898
*/
9999
async function getClassStates(elements: ElementArrayFinder, className: string) {
100100
return elements.map(async (element) => {
101-
let classes = await element.getAttribute('class');
101+
let classes = await element!.getAttribute('class');
102102
return classes.split(/ +/g).indexOf(className) >= 0;
103103
});
104104
}

e2e/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"declaration": true,
66
"emitDecoratorMetadata": true,
77
"experimentalDecorators": true,
8+
"strictNullChecks": true,
89
"inlineSources": true,
910
"lib": ["es2015"],
1011
"module": "commonjs",

src/cdk/tsconfig-build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"stripInternal": false,
88
"experimentalDecorators": true,
99
"noUnusedParameters": true,
10+
"strictNullChecks": true,
1011
"importHelpers": true,
1112
"newLine": "lf",
1213
"module": "es2015",

src/demo-app/checkbox/checkbox-demo.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export class MdCheckboxDemoNestedChecklist {
4141

4242
allComplete(task: Task): boolean {
4343
let subtasks = task.subtasks;
44+
45+
if (!subtasks) {
46+
return false;
47+
}
48+
4449
return subtasks.every(t => t.completed) ? true
4550
: subtasks.every(t => !t.completed) ? false
4651
: task.completed;

src/demo-app/data-table/data-table-demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Component} from '@angular/core';
22
import {PeopleDatabase} from './people-database';
33
import {PersonDataSource} from './person-data-source';
44

5-
export type UserProperties = 'userId' | 'userName' | 'progress' | 'color';
5+
export type UserProperties = 'userId' | 'userName' | 'progress' | 'color' | undefined;
66

77
@Component({
88
moduleId: module.id,
@@ -11,7 +11,7 @@ export type UserProperties = 'userId' | 'userName' | 'progress' | 'color';
1111
styleUrls: ['data-table-demo.css'],
1212
})
1313
export class DataTableDemo {
14-
dataSource: PersonDataSource;
14+
dataSource: PersonDataSource | null;
1515
propertiesToDisplay: UserProperties[] = [];
1616

1717
constructor(private _peopleDatabase: PeopleDatabase) {

src/demo-app/dialog/dialog-demo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component, Inject, ViewChild, TemplateRef} from '@angular/core';
22
import {DOCUMENT} from '@angular/platform-browser';
3-
import {MdDialog, MdDialogRef, MdDialogConfig, MD_DIALOG_DATA} from '@angular/material';
3+
import {MdDialog, MdDialogRef, MD_DIALOG_DATA} from '@angular/material';
44

55

66
@Component({
@@ -10,10 +10,10 @@ import {MdDialog, MdDialogRef, MdDialogConfig, MD_DIALOG_DATA} from '@angular/ma
1010
styleUrls: ['dialog-demo.css'],
1111
})
1212
export class DialogDemo {
13-
dialogRef: MdDialogRef<JazzDialog>;
13+
dialogRef: MdDialogRef<JazzDialog> | null;
1414
lastCloseResult: string;
1515
actionsAlignment: string;
16-
config: MdDialogConfig = {
16+
config = {
1717
disableClose: false,
1818
panelClass: 'custom-overlay-pane-class',
1919
hasBackdrop: true,

src/demo-app/ripple/ripple-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class RippleDemo {
1515
disabled = false;
1616
unbounded = false;
1717
rounded = false;
18-
radius: number = null;
18+
radius: number;
1919
rippleSpeed = 1;
2020
rippleColor = '';
2121

src/demo-app/snack-bar/snack-bar-demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class SnackBarDemo {
2121
open() {
2222
let config = new MdSnackBarConfig();
2323
config.duration = this.autoHide;
24-
config.extraClasses = this.addExtraClass ? ['party'] : null;
25-
this.snackBar.open(this.message, this.action && this.actionButtonLabel, config);
24+
config.extraClasses = this.addExtraClass ? ['party'] : undefined;
25+
this.snackBar.open(this.message, this.action ? this.actionButtonLabel : undefined, config);
2626
}
2727
}

src/demo-app/tsconfig-aot.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// TypeScript config that extends the demo-app tsconfig file. This config compiles the
1+
// TypeScript config that extends the demo-app tsconfig file. This config compiles the
22
// "main-aot.ts" file and also enables templage code generation / AOT. All paths need
33
// to be relative to the output directory.
44
{
@@ -7,6 +7,7 @@
77
"experimentalDecorators": true,
88
// TODO(paul): Remove once Angular has been upgraded and supports noUnusedParameters in AOT.
99
"noUnusedParameters": false,
10+
"strictNullChecks": true,
1011
"outDir": ".",
1112
"paths": {
1213
"@angular/material": ["./material"],

src/demo-app/tsconfig-build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"emitDecoratorMetadata": true,
77
"experimentalDecorators": true,
88
"noUnusedParameters": true,
9+
"strictNullChecks": true,
910
"lib": ["es6", "es2015", "dom"],
1011
"module": "commonjs",
1112
"moduleResolution": "node",

0 commit comments

Comments
 (0)