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

TypeScript Error When Importing GCS Types to index.d.ts #70

Closed
hiranya911 opened this issue Aug 15, 2017 · 5 comments
Closed

TypeScript Error When Importing GCS Types to index.d.ts #70

hiranya911 opened this issue Aug 15, 2017 · 5 comments
Assignees

Comments

@hiranya911
Copy link
Contributor

In v5.2.0 we added Cloud Storage support to the Admin SDK. As a part of this we made a few changes to the index.d.ts file:

import {Bucket} from '@google-cloud/storage';

declare namespace admin.storage {
  interface Storage {
    app: admin.app.App;
    bucket(name?: string): Bucket;
  }
}

Turns out this is not supported properly in TypeScript. It triggers the following error in downstream apps:

node_modules/firebase-admin/lib/index.d.ts(396,3): error TS2666: Exports and export assignments are not permitted in module augmentations.
npm ERR! Test failed.  See above for more details.

Simply having the import statement at the top-level of the file is sufficient to trigger the error.

Possible Solutions

  1. Not expose the GCS Bucket type in our API, and use any instead.
  2. Change our module declaration as follows:
// index.d.ts
declare module 'firebase-admin' {
}

export = admin;

This fixes the error, but I don't know if it has other consequences.

@byrondover
Copy link

Confirmed, 5.2.0 is borked. 😞

ERROR in ./functions/node_modules/firebase-admin/lib/index.d.ts
(397,3): error TS2666: Exports and export assignments are not permitted in module augmentations.

My vote would be for solution #1. In the mean time, reverting to 5.1.0 fixes the issue.

@hiranya911
Copy link
Contributor Author

This has been fixed in #71. Expect a 5.2.1 patch release soon.

@jspri
Copy link

jspri commented Sep 18, 2017

@hiranya911 can you investigate option 2? Would help to make the storage lib more usable.

@hiranya911
Copy link
Contributor Author

@Crazometer Yes, I can take a look.

Perhaps somebody who better understands the dependency model of Node.js/TypeScript can explain to us what this change implies to the overall operation of the SDK.

@hiranya911
Copy link
Contributor Author

@Crazometer I just sent out #87 to implement the 2nd option. If you can try it out, and give us some feedback that would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants