-
Notifications
You must be signed in to change notification settings - Fork 943
Enable Typescript strict flag for Storage #1935
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
// TODO: This disable can be removed and the 'ignoreRestArgs' option added to | ||
// the no-explicit-any rule when ESlint releases it. | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function triggerCallback(...args: any[]): void { |
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.
Should we follow the same pattern in handler() and change the signature as well? Something like:
function handler(success:boolean, ...args:any[])
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.
@@ -30,7 +30,7 @@ import * as type from './type'; | |||
* modified after this blob's construction. | |||
*/ | |||
export class FbsBlob { | |||
private data_: Blob | Uint8Array; | |||
private data_!: Blob | Uint8Array; |
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.
Can you explain to me what the bang here means?
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.
It is a way of us promising the compiler that this variable will be initialized before anything calls it. The compiler thinks data_ isn't definitively set in the constructor because there's an if
and 2 else if
s where it is set, but no else
. Since the constructor requires the data
param to be of a type that would meet all possible if
conditions, it should always get set in the constructor.
I can fix it by adding an else at the end that assigns data_
some default value, which seems risky unless you have a suggestion, or I can just look at the types and promise the compiler data_
is going to get set. Thoughts?
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.
Interesting. I have never seen this before. We have a bunch of code in Firestore that we could simplify this way. So keep it as is please :)
mappings.push(new Mapping('generation')); | ||
mappings.push(new Mapping('metageneration')); | ||
mappings.push(new Mapping('name', 'fullPath', true)); | ||
const mappings: Array<Mapping<string> | Mapping<number>> = []; |
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.
Is this not just const mappings: Mappings
?
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.
Oh right, done.
function validator(path: string): void { | ||
if (/^[A-Za-z]+:\/\//.test(path)) { | ||
function validator(path: unknown): void { | ||
if (/^[A-Za-z]+:\/\//.test(path as 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.
If you want to go the extra mile, then I would suggest we also validate explicitly that path
is a string. Optional.
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.
Will give it a shot.
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.
Can you do the same thing for refFromURL
below? Thanks!
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.
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.
Thanks!
Enable
"strict": true
Typescript flag for Storage.