@@ -4754,28 +4754,26 @@ namespace ts {
4754
4754
}
4755
4755
4756
4756
function getPropertiesOfUnionOrIntersectionType(type: UnionOrIntersectionType): Symbol[] {
4757
- for (const current of type.types) {
4758
- for (const prop of getPropertiesOfType(current)) {
4759
- getUnionOrIntersectionProperty(type, prop.name);
4760
- }
4761
- // The properties of a union type are those that are present in all constituent types, so
4762
- // we only need to check the properties of the first type
4763
- if (type.flags & TypeFlags.Union) {
4764
- break;
4765
- }
4766
- }
4767
- const props = type.resolvedProperties;
4768
- if (props) {
4769
- const result: Symbol[] = [];
4770
- props.forEach(prop => {
4771
- // We need to filter out partial properties in union types
4772
- if (!(prop.flags & SymbolFlags.SyntheticProperty && (<TransientSymbol>prop).isPartial)) {
4773
- result.push(prop);
4757
+ if (!type.resolvedProperties) {
4758
+ const members = createMap<Symbol>();
4759
+ for (const current of type.types) {
4760
+ for (const prop of getPropertiesOfType(current)) {
4761
+ if (!members.has(prop.name)) {
4762
+ const combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name);
4763
+ if (combinedProp) {
4764
+ members.set(prop.name, combinedProp);
4765
+ }
4766
+ }
4774
4767
}
4775
- });
4776
- return result;
4768
+ // The properties of a union type are those that are present in all constituent types, so
4769
+ // we only need to check the properties of the first type
4770
+ if (type.flags & TypeFlags.Union) {
4771
+ break;
4772
+ }
4773
+ }
4774
+ type.resolvedProperties = getNamedMembers(members);
4777
4775
}
4778
- return emptyArray ;
4776
+ return type.resolvedProperties ;
4779
4777
}
4780
4778
4781
4779
function getPropertiesOfType(type: Type): Symbol[] {
@@ -4943,7 +4941,7 @@ namespace ts {
4943
4941
// these partial properties when identifying discriminant properties, but otherwise they are filtered out
4944
4942
// and do not appear to be present in the union type.
4945
4943
function getUnionOrIntersectionProperty(type: UnionOrIntersectionType, name: string): Symbol {
4946
- const properties = type.resolvedProperties || (type.resolvedProperties = createMap<Symbol>());
4944
+ const properties = type.propertyCache || (type.propertyCache = createMap<Symbol>());
4947
4945
let property = properties.get(name);
4948
4946
if (!property) {
4949
4947
property = createUnionOrIntersectionProperty(type, name);
0 commit comments