google-cloud-node icon indicating copy to clipboard operation
google-cloud-node copied to clipboard

Add ability to include Storage types

Open steffnay opened this issue 3 years ago • 3 comments

In @google-cloud/bigquery we created a custom File type where we were supposed to be using a @google-cloud/storage File type.

export interface File {
  bucket: any;
  kmsKeyName?: string;
  userProject?: string;
  name: string;
  generation?: number;
}

The storage npm module includes these types, but is currently installed as a devDependency. Unless it's included as a production dependency, the types would not be included. The storage module is fairly large, and only really needed for types. It would be ideal to have a way to access these types.

steffnay avatar Aug 04 '20 20:08 steffnay

This is a super interesting problem. If we shipped separate @types packages for our libraries, we would be able to do that, but generally that's not recommended if a library ships it's own types. I don't know the answer to this one! @bcoe for his thoughts.

JustinBeckwith avatar Aug 04 '20 21:08 JustinBeckwith

@steffnay what happens if you attempt to coerce it into that type?

import {File} from '@google-cloud/storage'
fileFromBigQuery as File

bcoe avatar Aug 06 '20 18:08 bcoe

I agree as a typescript dev its a real hassle, maybe you could just add a export to all the types so we can access them like that?

Artrix9095 avatar Aug 16 '20 04:08 Artrix9095