Skip to content

Compiler hangs on union of enums with a large number of elements #12535

Closed
@NoelAbrahams

Description

@NoelAbrahams

TypeScript Version: 2.1 RC / (Version installed with VS 2017)

Code

namespace enums {

    export const enum A {
        a1,
        a2,
        a3,
       // ... elements omitted for the sake of clarity
        a75,
        a76,
        a77,
    }

    export const enum B {
        b1,
        b2,
       // ... elements omitted for the sake of clarity
        b86,
        b87,
    }

    export const enum C {
        c1,
        c2,
       // ... elements omitted for the sake of clarity
        c210,
        c211,
    }

    export type Genre = A | B | C;
}

type Foo = {
    genreId: enums.Genre;
};

type Bar = {

    genreId: enums.Genre;
};

type FooBar = Foo & Bar;

function foo(so: any) {

    const val = so as FooBar;

    const isGenre = val.genreId;

    return isGenre;
}

Expected behavior:

Compilation in a few hundred milliseconds

Actual behavior:

Compilation took 1 minute 5 seconds for the code sample above (i.e. where the omitted enum elements are filled out exactly.) In the actual code, the build hangs indefinitely.

This bit of code was working fine with TS 2.0.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions