Optimize checking involving large discriminated union types (#42556)

* No array literal subtype reduction when contextual type is present

* Accept new baselines

* Fast path in relations and filtering of pure discriminated union types

* Create maps for mixed unions, but not for small or primitive only unions

* Create many-to-many mapping with certain limits, also use in CFA

* Use constituent maps in CFA for switch statements, cleanup, add comments

* Revert change to apparent contextual type / better criteria for map eligibility

* Deduplicate array literal element types

* Accept new baselines

* Filter in false case only when discriminant property has unit type

* Only subtype reduce unions with less than 100 distinct types

* Accept new baselines

* Caching and quick discriminant checks in subtype reduction

* Accept new baselines

* Remove deduplication logic now that subtype reduction was optimized
This commit is contained in:
Anders Hejlsberg authored and GitHub committed 2021-02-28 16:38:20 -08:00
1 parent 1db60035d6
commit ef2c98fc35
4 files changed
+166 -36

No files matched your search

+4
View File
@@ -5292,6 +5292,10 @@ namespace ts {
regularType?: UnionType;
/* @internal */
origin?: Type; // Denormalized union, intersection, or index type in which union originates
/* @internal */
keyPropertyName?: __String; // Property with unique unit type that exists in every object/intersection in union type
/* @internal */
constituentMap?: ESMap<TypeId, Type>; // Constituents keyed by unit type discriminants
}
export interface IntersectionType extends UnionOrIntersectionType {