You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Compiler hangs on union of enums with a large number of elements #12535
TypeScript Version: 2.1 RC / (Version installed with VS 2017)
Code
namespaceenums{exportconstenumA{a1,a2,a3,// ... elements omitted for the sake of claritya75,a76,a77,}exportconstenumB{b1,b2,// ... elements omitted for the sake of clarityb86,b87,}exportconstenumC{c1,c2,// ... elements omitted for the sake of clarityc210,c211,}exporttypeGenre=A|B|C;}typeFoo={genreId: enums.Genre;};typeBar={genreId: enums.Genre;};typeFooBar=Foo&Bar;functionfoo(so: any){constval=soasFooBar;constisGenre=val.genreId;returnisGenre;}
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.
Anders Hejlsberg (@ahejlsberg), not sure if it has any bearing but in the actual problem code every enum value is unique (i.e. the elements of A, B and C do not share any values). I hope that's still okay.
Activity
ahejlsberg commentedon Nov 28, 2016
This is an issue caused by #11717. We need to deduplicate intersections before we distribute them over union types. Looks like an easy fix.
NoelAbrahams commentedon Nov 28, 2016
Anders Hejlsberg (@ahejlsberg), not sure if it has any bearing but in the actual problem code every enum value is unique (i.e. the elements of A, B and C do not share any values). I hope that's still okay.