You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The callback typings for on and off are not consistent and effect errors when using TypeScript 2.6 and strictFunctionTypes.
With the code in this issue (in the Relevant Code section), this error is effected:
TSError: ⨯ Unable to compile TypeScript
index.ts (4,24): Argument of type '(a: DataSnapshot | null, b?: string | undefined) => any' is not assignable to parameter of type '((a: DataSnapshot, b?: string | null | undefined) => any) | undefined'.
Type '(a: DataSnapshot | null, b?: string | undefined) => any' is not assignable to type '(a: DataSnapshot, b?: string | null | undefined) => any'.
Types of parameters 'b' and 'b' are incompatible.
Type 'string | null | undefined' is not assignable to type 'string | undefined'.
Type 'null' is not assignable to type 'string | undefined'. (2345)
at getOutput (...\node_modules\ts-node\src\index.ts:307:15)
at ...\node_modules\ts-node\src\index.ts:336:16
at Object.compile (...\node_modules\ts-node\src\index.ts:498:11)
at Module.m._compile (...\node_modules\ts-node\src\index.ts:392:43)
at Module._extensions..js (module.js:635:10)
at Object.require.extensions.(anonymous function) [as .ts] (...\node_modules\ts-node\src\index.ts:395:12)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
The problem is that the on method returns a callback with a signature that differs from that of the callback the off method accepts.
In particular, it's the type of the optional b parameter. In the callback returned by on its type is b?: string, but in the callback accepted by off its type is b?: string | null.
Steps to reproduce:
Compile the code included below using TypeScript 2.6.1, with the strictFunctionTypes option enabled or with the strict option set to true.
Sorry for the delay here. I tried to reproduce this using Typescript: 3.7.2 with the latest version of Firebase JS SDK (7.4.0) but can't seem to replicate it.
I would be happy to investigate further if you could provide a MCV example that I can run locally.
The steps to reproduce the problem were included in the initial PR description. I would be surprised if it were not reproducible using the versions that were specified. That it cannot be reproduced - more than two years later - with the current versions does not surprise me. If you have attempted to reproduce it with the latest versions and have been unable to do so, closing the issue would seem the appropriate course of action.
We really apologize for the inconvenience this may have caused you and weren't able to get back soon. It may seem to be addressed in the previous releases. I'll be closing this issue now as part of the issue cleanup effort.
If you're still interested in working on this case and want to continue the discussion, just leave a comment here and we are happy to re-open this. Thank you for understanding.
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
The callback typings for
on
andoff
are not consistent and effect errors when using TypeScript 2.6 andstrictFunctionTypes
.With the code in this issue (in the Relevant Code section), this error is effected:
The problem is that the
on
method returns a callback with a signature that differs from that of the callback theoff
method accepts.In particular, it's the type of the optional
b
parameter. In the callback returned byon
its type isb?: string
, but in the callback accepted byoff
its type isb?: string | null
.Steps to reproduce:
Compile the code included below using TypeScript 2.6.1, with the
strictFunctionTypes
option enabled or with thestrict
option set totrue
.Relevant Code:
The text was updated successfully, but these errors were encountered: