Skip to content

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

Merged
merged 23 commits into from
Jun 3, 2019
Merged

Conversation

hsubox76
Copy link
Contributor

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.

Copy link
Member

@jamesdaniels jamesdaniels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM rxfire

Copy link
Member

@yuchenshi yuchenshi left a 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

@googlebot
Copy link

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 cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a 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) {
Copy link
Member

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.

Copy link
Contributor Author

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 || '']);
Copy link
Member

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! ?

Copy link
Contributor Author

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) {
Copy link
Member

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.

@@ -226,7 +226,7 @@ export class Reference {
prefixes: [],
items: []
};
return this.listAllHelper(accumulator, null).then(() => accumulator);
return this.listAllHelper(accumulator, undefined).then(() => accumulator);
Copy link
Member

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

Copy link
Contributor Author

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/);
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -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.
Copy link
Member

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.

Copy link
Contributor Author

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.

@hsubox76 hsubox76 merged commit 6668b59 into master Jun 3, 2019
@hsubox76 hsubox76 deleted the ch-strict branch June 5, 2019 17:11
@firebase firebase locked and limited conversation to collaborators Oct 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants