TypeScript newable and enum reference

I have an external JavaScript SDK that I use. One of these modules Blobis new, but also provides an enumeration FooEnum(members Barand Baz).

The code for using this SDK in JavaScript looks like this:

const blobInstance = new Sdk.Blob();
const fooType = Sdk.Blob.FooEnum.Baz;

Now I am trying to write an interface that I can use for this SDK to give me some type safety. Here is what I got so far:

interface BlobInterface { }

enum Foo {
    Bar,
    Baz
}

interface Sdk {
    Blob: {
        new(): BlobInterface;
        FooEnum: Foo;
    }
}

My problem, however, is that when I refer to it Blob.FooEnum, it considers FooEnumitself to be a member of the enumeration Foo(i.e., it considers that it is Baror Baz) and therefore does not allow me to get Bazfrom it.

TypeScript, Blob.FooEnum ?

+6
1

Foo - . , Bar Baz 0 1 ( 0 1, "Bar" "Baz" .). Foo.Bar Foo.Baz. : Foo Foo.

(, class Bar {}), Bar , Bar . , Bar Bar.

, , Foo Bar, typeof :

interface Sdk {
    Blob: {
        FooEnum: typeof Foo;
    }
}

FooEnum , Foo, .

!

+3

All Articles