-
Notifications
You must be signed in to change notification settings - Fork 943
Apply strictNullChecks to all packages except database #1805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM rxfire
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for packages/testing
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the ℹ️ Googlers: Go here for more info. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question remaining about the Storage tests but LGTM. Thanks.
@@ -110,7 +110,7 @@ export class Service implements FirebaseFunctions, FirebaseService { | |||
* @param origin The origin of the local emulator, such as | |||
* "http://localhost:5005". | |||
*/ | |||
useFunctionsEmulator(origin: string) { | |||
useFunctionsEmulator(origin: string | null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think this function is intended to reset the emulator. Plus it's an API change. I would just leave it to only accept string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, got rid of the test line that uses null to reset this. Doesn't seem necessary.
@@ -147,7 +147,7 @@ describe('RxFire Database', () => { | |||
count = count + 1; | |||
const { event, snapshot } = change; | |||
expect(event).to.equal(ListenEvent.added); | |||
expect(snapshot.val()).to.eql(data[snapshot.key]); | |||
expect(snapshot.val()).to.eql(data[snapshot.key || '']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could it happen? Should it be snapshot.key!
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically it could be null but if it ever happens I think it's so far back in the stack that it's beyond the scope of this test to check for it. Changed to snapshot.key!
@@ -58,11 +59,15 @@ function fromBackendResponse( | |||
items: [], | |||
nextPageToken: resource['nextPageToken'] | |||
}; | |||
const bucket = authWrapper.bucket(); | |||
if (bucket === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why I don't like mixing ==null
in the code. I have to look up authWrapper.bucket()
signature to understand if it is actually meant to be ==
and made a mistake.
packages/storage/src/reference.ts
Outdated
@@ -226,7 +226,7 @@ export class Reference { | |||
prefixes: [], | |||
items: [] | |||
}; | |||
return this.listAllHelper(accumulator, null).then(() => accumulator); | |||
return this.listAllHelper(accumulator, undefined).then(() => accumulator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just omit the second param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -111,7 +112,7 @@ describe('Firebase Storage > Service', () => { | |||
const error = testShared.assertThrows(() => { | |||
new Service(testShared.fakeApp, xhrIoPool, 'gs://bucket/object/'); | |||
}, 'storage/invalid-default-bucket'); | |||
assert.match(error.message, /Invalid default bucket/); | |||
error && assert.match(error.message, /Invalid default bucket/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.match()
should always execute. testShared.assertThrows()
returns a FirebaseStorageError
, I don't think we need to null check error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -135,7 +136,7 @@ describe('Firebase Storage > Service', () => { | |||
const error = testShared.assertThrows(() => { | |||
service.refFromURL('path/to/child'); | |||
}, 'storage/invalid-argument'); | |||
assert.match(error.message, /invalid/i); | |||
error && assert.match(error.message, /invalid/i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
packages/util/src/crypt.ts
Outdated
@@ -49,12 +49,12 @@ const stringToByteArray = function(str) { | |||
/** | |||
* Turns an array of numbers into the string given by the concatenation of the | |||
* characters to which the numbers correspond. | |||
* @param {Array<number>} bytes Array of numbers representing characters. | |||
* @param {number[]} bytes Array of numbers representing characters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the param/return types should be moved from the comment to the definition directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, fixed similar in rest of file.
Applying Typescript option strictNullChecks to all packages and fixing existing code where it violates this rule.
Database has an override on this for now because it has so many strict null check violations to fix that it should be a separate PR.