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

Help needed with use with Typescript #105

Open
rickhoro opened this issue Dec 6, 2020 · 1 comment
Open

Help needed with use with Typescript #105

rickhoro opened this issue Dec 6, 2020 · 1 comment

Comments

@rickhoro
Copy link

rickhoro commented Dec 6, 2020

I've gotten this to work with node and typescript with the associated @types/backblaze-b2 package but I have not been able to figure out how to use the interfaces defined in the index.d.ts file in my node js program. For example, I am trying to define a BucketInfo interface that can be used to extract data from a getBucket() call. In the BucketInfo interface, I would like to define a bucketType: BucketType property, but I cannot figure out how to get access to the BucketType type definition in the index.d.ts file in @types/backblaze-b2. Can anyone suggest a solution?

Currently, I am importing the b2 definition like this:

import B2 = require("./node_modules/@types/backblaze-b2");

This allows me to call B2 as a constructor, but I don't seem to be able to use it as a namespace.

I'm not sure if this is appropriate to post as an issue, but it would be helpful to add this to the examples in the doc, so I suppose it is valid.

@EricChen1248
Copy link

I'm not sure why you need to use it like this. DefinitelyType (the @type stuff) is purely for Typescript to fetch type definition. When you are importing, you should always import the original package, i.e.
import B2 from "backblaze-b2"

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

No branches or pull requests

2 participants