Switch to strict null checks

This commit is contained in:
Mitya Kononchuk
2017-11-14 17:54:06 +01:00
parent 8ca6a6e423
commit a9ec5e7fe0
2 changed files with 9 additions and 9 deletions

View File

@@ -33,7 +33,7 @@ describe("Included matchers:", () => {
var b = a;
expect(a).toBe(b);
expect(a).not.toBe(null);
expect(a).not.toBe(24);
});
describe("The 'toEqual' matcher", () => {
@@ -83,7 +83,7 @@ describe("Included matchers:", () => {
});
it("The 'toBeNull' matcher compares against null", () => {
var a: string = null;
var a: string | null = null;
var foo = "foo";
expect(null).toBeNull();
@@ -92,14 +92,14 @@ describe("Included matchers:", () => {
});
it("The 'toBeTruthy' matcher is for boolean casting testing", () => {
var a: string, foo = "foo";
var a: string | undefined, foo = "foo";
expect(foo).toBeTruthy();
expect(a).not.toBeTruthy();
});
it("The 'toBeFalsy' matcher is for boolean casting testing", () => {
var a: string, foo = "foo";
var a: string | undefined, foo = "foo";
expect(a).toBeFalsy();
expect(foo).not.toBeFalsy();
@@ -1026,19 +1026,19 @@ var myReporter: jasmine.CustomReporter = {
specDone: (result: jasmine.CustomReporterResult) => {
console.log("Spec: " + result.description + " was " + result.status);
//tslint:disable-next-line:prefer-for-of
for (var i = 0; i < result.failedExpectations.length; i++) {
for (var i = 0; result.failedExpectations && i < result.failedExpectations.length; i++) {
console.log("Failure: " + result.failedExpectations[i].message);
console.log("Actual: " + result.failedExpectations[i].actual);
console.log("Expected: " + result.failedExpectations[i].expected);
console.log(result.failedExpectations[i].stack);
}
console.log(result.passedExpectations.length);
console.log(result.passedExpectations && result.passedExpectations.length);
},
suiteDone: (result: jasmine.CustomReporterResult) => {
console.log('Suite: ' + result.description + ' was ' + result.status);
//tslint:disable-next-line:prefer-for-of
for (var i = 0; i < result.failedExpectations.length; i++) {
for (var i = 0; result.failedExpectations && i < result.failedExpectations.length; i++) {
console.log('AfterAll ' + result.failedExpectations[i].message);
console.log(result.failedExpectations[i].stack);
}

View File

@@ -11,7 +11,7 @@
],
"noImplicitAny": true,
"noImplicitThis": false,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": false,
"baseUrl": "../",
"typeRoots": [
@@ -21,4 +21,4 @@
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
}
}