Skip to content

Turn on Typescript strict option for Firestore #1941

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

Closed
wants to merge 2 commits into from

Conversation

hsubox76
Copy link
Contributor

@hsubox76 hsubox76 commented Jul 3, 2019

Set strict: true in Typescript compiler options. This required setting a lot of initial values for variables or promising the compiler (with !) that these values would be set before being used, so please check I have guessed the correct values or that the guarantees are correct.

@hsubox76 hsubox76 requested a review from mikelehen July 3, 2019 23:06
Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

I'm about to be OOO for almost 2 weeks and I think this probably needs a bit more scrutiny than I can give it today. Ideally I think we should try to avoid using ! as much as possible, since I think this basically just bypasses the strict check and TypeScript will happily let us fail to initialize the variable, right? But I'm not sure how hard it is to do that, and it probably depends on each case, and maybe it's not something we want to invest too much time in right now... Not sure.

Anyway, perhaps @schmidt-sebastian has time to look at this? Else, I can work through it when I get back (~7/17).

@@ -134,7 +134,7 @@ export class FirebaseCredentialsProvider implements CredentialsProvider {
private tokenListener: ((token: string | null) => void) | null = null;

/** Tracks the current User. */
private currentUser: User;
private currentUser?: User;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be initialized to User.UNAUTHENTICATED instead.

@@ -192,7 +192,7 @@ export class FirebaseCredentialsProvider implements CredentialsProvider {
typeof tokenData.accessToken === 'string',
'Invalid tokenData returned from getToken():' + tokenData
);
return new OAuthToken(tokenData.accessToken, this.currentUser);
return new OAuthToken(tokenData.accessToken, this.currentUser!);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove ! after above suggestion.

@hsubox76
Copy link
Contributor Author

hsubox76 commented Jul 4, 2019

This isn't urgent so I can definitely put this on the back burner until someone has time to properly review it.

@mikelehen
Copy link
Contributor

I've addressed the strict violations and enabled strict mode via #2078. Thanks!

@mikelehen mikelehen closed this Aug 12, 2019
@firebase firebase locked and limited conversation to collaborators Oct 9, 2019
@hsubox76 hsubox76 deleted the ch-firestore-strict branch January 8, 2020 21:20
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.

2 participants