Skip to content

Firebase 9 and Typescript typings error #4913

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
jmc420 opened this issue May 15, 2021 · 5 comments
Closed

Firebase 9 and Typescript typings error #4913

jmc420 opened this issue May 15, 2021 · 5 comments

Comments

@jmc420
Copy link

jmc420 commented May 15, 2021

[REQUIRED] Describe your environment

  • Operating System version: OSX 11.2.3_
  • Browser version: 90_
  • Firebase SDK version: 9.0.0-beta.2_
  • Firebase Product: _auth (auth, database, storage, etc)

[REQUIRED] Describe the problem

I am getting weird typing errors generated by the Typescript compiler that didn't happen with Firebase 8.

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:1097:47 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1097 static readonly FACEBOOK_SIGN_IN_METHOD = SignInMethod.FACEBOOK;

If I set isolatedModules to false in tsconfig.json, the errors go away.

I have upgraded to the latest version of Typescript (4.2.4) but it makes no difference.

This is the compiler output:

[17:20:25] Starting compilation in watch mode...

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:573:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

573 [AuthErrorCode.ARGUMENT_ERROR]: {
~~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:576:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

576 [AuthErrorCode.DEPENDENT_SDK_INIT_BEFORE_AUTH]: {
~~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:579:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

579 [AuthErrorCode.INTERNAL_ERROR]: {
~~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:582:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

582 [AuthErrorCode.NO_AUTH_EVENT]: {
~~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:585:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

585 [AuthErrorCode.MFA_REQUIRED]: {
~~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:589:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

589 [AuthErrorCode.INVALID_CORDOVA_CONFIGURATION]: {
~~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:965:35 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

965 static readonly PROVIDER_ID = ProviderId.PASSWORD;
~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:969:53 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

969 static readonly EMAIL_PASSWORD_SIGN_IN_METHOD = SignInMethod.EMAIL_PASSWORD;
~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:973:49 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

973 static readonly EMAIL_LINK_SIGN_IN_METHOD = SignInMethod.EMAIL_LINK;
~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:977:27 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

977 readonly providerId = ProviderId.PASSWORD;
~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:1097:47 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1097 static readonly FACEBOOK_SIGN_IN_METHOD = SignInMethod.FACEBOOK;
~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:1099:35 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1099 static readonly PROVIDER_ID = ProviderId.FACEBOOK;
~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:1352:45 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1352 static readonly GITHUB_SIGN_IN_METHOD = SignInMethod.GITHUB;
~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:1354:35 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1354 static readonly PROVIDER_ID = ProviderId.GITHUB;
~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:1421:45 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1421 static readonly GOOGLE_SIGN_IN_METHOD = SignInMethod.GOOGLE;
~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:1423:35 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1423 static readonly PROVIDER_ID = ProviderId.GOOGLE;
~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:2280:35 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

2280 static readonly PROVIDER_ID = ProviderId.PHONE;
~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:2282:44 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

2282 static readonly PHONE_SIGN_IN_METHOD = SignInMethod.PHONE;
~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:2284:27 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

2284 readonly providerId = ProviderId.PHONE;
~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:3206:46 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

3206 static readonly TWITTER_SIGN_IN_METHOD = SignInMethod.TWITTER;
~~~~~~~~~~~~

node_modules/@firebase/auth/dist/auth-exp-public.d.ts:3208:35 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

3208 static readonly PROVIDER_ID = ProviderId.TWITTER;
~~~~~~~~~~

[17:20:33] Found 21 errors. Watching for file changes.

@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.

@Feiyang1
Copy link
Member

Yeah, firebase/auth exports some const enums, which don't work with isolatedModules mode. May I ask why you enable isolatedModules flag?

The reason we export const enums instead of normal enums is because Typescript compiles normal enums to javascript in a way that makes them not tree shakable. That means all these enum objects will be included in your app even if you don't use them. One way we can solve it is to define these maps using plain javascript objects instead of typescript enums.

@sam-gc

@jmc420
Copy link
Author

jmc420 commented May 19, 2021

That makes sense.

I’ve set isolate modules to false; I can’t remember why I set it to true :-)

@jmc420 jmc420 closed this as completed May 19, 2021
@peferron
Copy link

@Feiyang1 Vite requires isolatedModules to be enabled: https://vitejs.dev/guide/features.html#typescript

@Feiyang1
Copy link
Member

Opened an issue to track.

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

No branches or pull requests

5 participants