Skip to content
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

Cannot find namespace 'firebase'.ts(2503) for with firebase/compat/app and "moduleResolution": "bundler" #7279

Closed
segevfiner opened this issue May 5, 2023 · 8 comments · Fixed by #7294

Comments

@segevfiner
Copy link
Contributor

[REQUIRED] Describe your environment

  • Operating System version: macOS 13.3.1 (a)
  • Browser version: Google Chrome 113.0.5672.63
  • Firebase SDK version: 9.21.0
  • Firebase Product: sdk (auth, database, storage, etc)

[REQUIRED] Describe the problem

With the new "moduleResolution": "bundler" mode of TypeScript 5.0+, TypeScript errors on attempting to access any type from the firebase global namespace with firebase/compat/app and friends imported. It works with "moduleResolution": "node".

Steps to reproduce:

  1. Clone https://github.com/segevfiner/firebase-types-issue
  2. pnpm i
  3. pnpm type-check.
  4. If you set "moduleResolution": "node" in tsconfig.app.json it will work, but it should work with the new moduleResolution mode as well.

Relevant Code:

https://github.com/segevfiner/firebase-types-issue

@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@jbalidiong
Copy link
Contributor

Hi @segevfiner, thanks for the report. I was able to reproduce the behavior. Let me check what we can do for this issue or bring someone here that can provide more context about it. I’ll update this thread if I have any information to share.

@jbalidiong jbalidiong added the bug label May 5, 2023
@hsubox76
Copy link
Contributor

hsubox76 commented May 5, 2023

Are you seeing this error when you run pnpm type-check or just in the IDE tooltip? We've only been able to see it in the tooltip but the tsc compliation seems to finish with no errors?

@hsubox76
Copy link
Contributor

hsubox76 commented May 5, 2023

Ok, the immediate issue is that when you use moduleResolution: bundler, firebase/compat/app grabs typings from here (just firebase/app-compat types):
https://github.com/firebase/firebase-js-sdk/blob/master/packages/app-compat/package.json#L14

instead of here (giant index.d.ts file for all compat typings, the expected type source for compat users):
https://github.com/firebase/firebase-js-sdk/blob/master/packages/firebase/package.json#L231

Not sure why there's individual compat package typings, I didn't think they worked. Will dig further into it.

@hsubox76
Copy link
Contributor

hsubox76 commented May 5, 2023

I think it's something we overlooked in #6307 . We should have copied what was in the top level typings field into the exports.types field. Should be able to fix.

@hsubox76
Copy link
Contributor

hsubox76 commented May 5, 2023

We're still going to try to fix this either way but I'm just curious why you're using the compat libraries, is it a legacy application that you're not ready to migrate?

@segevfiner
Copy link
Contributor Author

Yep. It's an application we are going to migrate someday, but it's hard to get time for tech debt where I work at.

@Sejal1101
Copy link

Kindly assign me this issue , if it still exists

@firebase firebase locked and limited conversation to collaborators Jun 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants