-
Notifications
You must be signed in to change notification settings - Fork 927
Enable noImplicitAny Typescript compiler flag #1862
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.
Approval for packages/testing
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.
Small question regarding the underscore used in imports, but other Storage LGTM.
import { | ||
FirebaseServiceFactory, | ||
_FirebaseNamespace | ||
} from '@firebase/app-types/private'; |
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 this just be FirebaseNamespace
? It's not immediately obvious to me why it needs an underscore, but I am willing to learn :)
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.
Hm, I guess we have:
import { FirebaseNamespace } from '@firebase/app-types';
import { _FirebaseNamespace } from '@firebase/app-types/private';
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.
Sure, the public FirebaseNamespace
type doesn't have an INTERNAL
property which causes a TS error on line 54.
@@ -163,7 +163,7 @@ export function list( | |||
pageToken?: string | null, | |||
maxResults?: number | null | |||
): RequestInfo<ListResult> { | |||
let urlParams = {}; | |||
let urlParams: { [key: string]: 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.
We have another PR pending that removes any
from Storage. Can you use unknown
here?
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.
I actually just saw that there was a UrlParams
type so I used that. The only change is I have to explicitly cast maxResults
to string if that's okay.
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.
Oops I guess it wasn't okay. I changed UrlParams to accept string | number
values, that seems like a better idea.
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 for tackling this! The Firestore changes mostly look good, but I'm not wild about introducing @ts-ignore
exceptions into our code, so I've taken a crack at fixing them in #1882.
packages/app/index.node.ts
Outdated
import { XMLHttpRequest } from 'xmlhttprequest'; | ||
// Node specific packages. | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
const Storage = require('dom-storage'); |
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.
What's the motivation behind the change?
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.
dom-storage
and xmlhttprequest
don't have types so the type of Storage
and XMLHttpRequest
is implicitly any
. Maybe it would be simpler to just @ts-ignore
and explain it is a node package.
@@ -80,6 +80,7 @@ export function createFirebaseNamespaceCore( | |||
// | |||
// import * as firebase from 'firebase'; | |||
// which becomes: var firebase = require('firebase'); | |||
// @ts-ignore |
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.
As discussed, please cast to any and use eslint suppression instead of @ts-ignore.
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/functions/src/serializer.ts
Outdated
function mapValues(o: object, f: (any) => any): object { | ||
let result = {}; | ||
function mapValues(o: { [key: string]: any }, f: (arg0: any) => any): object { | ||
let result: { [key: string]: 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.
should use unknown
instead. No action is needed . Explicit any is being tackled in eslint PRs.
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.
try { | ||
sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received'); | ||
if (sizeString === 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 check is not needed. parseInt
will produce NaN
which will be caught by isNaN
check.
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.
@@ -212,7 +212,8 @@ export function loadFirestoreRules( | |||
project: `projects/${options.projectId}`, | |||
rules: { files: [{ content: options.rules }] } | |||
}, | |||
(err, resp) => { | |||
// @ts-ignore Defined in protobuf. |
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 we use unknown
type here?
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.
resolve()
won't accept unknown
packages/util/src/jwt.ts
Outdated
@@ -18,26 +18,34 @@ | |||
import { base64Decode } from './crypt'; | |||
import { jsonEval } from './json'; | |||
|
|||
interface Claims { | |||
[key: string]: object | number | string | boolean; |
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.
just use {}
as type ? {}
also includes symbol
, but it should be fine.
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/jwt.ts
Outdated
if (typeof claims === 'object' && claims.hasOwnProperty('iat')) { | ||
return claims['iat']; | ||
return claims['iat'] as number | 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.
Should it just be 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.
Done.
packages/util/src/obj.ts
Outdated
@@ -18,12 +18,20 @@ | |||
/* eslint-disable */ | |||
// will enable after https://github.com/firebase/firebase-js-sdk/pull/1811 is merged | |||
|
|||
interface UtilObject<V> { | |||
[key: string]: V; | |||
[index: number]: V; |
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.
No need to define a number index. All number indexing are string indexing under the hood.
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.
Weird, I was previously getting a lot of errors in places that used this functions with number-indexed objects but I guess those errors got fixed on the consuming end. Done.
* Fix packages/firestore/ usages of @ts-ignore. I left the equality_matcher.ts ones for the code we copy/pasted in, but fixed the rest.
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 Firestore.
Enabled noImplicitAny Typescript compiler flag on all packages with an exception for database, which would require extensive updates out of scope for this PR.