Currently, I am utilizing an external SDK built in JavaScript. One particular module within this SDK, called Blob
, is both new-able and contains an enum named FooEnum
with the members Bar
and Baz
.
To implement this SDK in JavaScript, the code looks like this:
const blobInstance = new Sdk.Blob();
const fooType = Sdk.Blob.FooEnum.Baz;
Now, my aim is to create an interface that allows me to cast this SDK for added type safety. Here's what I have managed to come up with so far:
interface BlobInterface { }
enum Foo {
Bar,
Baz
}
interface Sdk {
Blob: {
new(): BlobInterface;
FooEnum: Foo;
}
}
However, I am facing an issue where TypeScript assumes that when referencing Blob.FooEnum
, it considers FooEnum
to be a member of the enum itself (such as Bar
or Baz
) which then restricts me from accessing Baz
.
Is there a way to instruct TypeScript that Blob.FooEnum
actually refers to the enum directly rather than being a member of the enum?