Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@NoelAbrahams

Description

@NoelAbrahams
Issue body actions

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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.