Skip to content

Using typeof with a class before its declaration results in an error #15307

@voithos

Description

@voithos

TypeScript Version: 2.3-rc

Code

const foo = typeof Bar;
class Bar {}

Expected behavior:
The code should compile properly. (And did compile fine in 2.2.1)

Actual behavior:
This results in a compilation error, "Class 'Bar' used before its declaration." Flipping the order fixes the problem.

In our case, the typeof Bar is actually used in an extends Foo<typeof Bar> clause of e.g. an interface declaration, but it exhibits the same behavior as this simpler example.

Alternatively, perhaps this was a bug in 2.2.1?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions