TypeScript Version: 3.4.5, 3.5.0-dev.20190523
Search Terms:
Code
type IndexFirst = {[x: string]: string} | {x: string};
type IndexLast = {p: string} | {[p: string]: string};
Expected behavior:
type.getProperties() to return an array of one symbol for each of the type alias declarations.
Actual behavior:
For IndexFirst type.getProperties() returns an empty array.
For IndexLast type.getProperties() returns an array of one symbol.
AFAICT this is caused by an early break in getPropertiesOfUnionOrIntersectionType:
// The properties of a union type are those that are present in all constituent types, so
// we only need to check the properties of the first type
That's not quite correct if there are index signatures. Iterating through the rest of the union constituents would fix this. getPropertyOfUnionOrIntersectionType already strips properties not present in all constituents. So this is probably a performance optimization and shouldn't simply be removed. Maybe we could stop after the first constituent that has no index signature.
TypeScript Version: 3.4.5, 3.5.0-dev.20190523
Search Terms:
Code
Expected behavior:
type.getProperties()to return an array of one symbol for each of the type alias declarations.Actual behavior:
For
IndexFirsttype.getProperties()returns an empty array.For
IndexLasttype.getProperties()returns an array of one symbol.AFAICT this is caused by an early break in
getPropertiesOfUnionOrIntersectionType:That's not quite correct if there are index signatures. Iterating through the rest of the union constituents would fix this.
getPropertyOfUnionOrIntersectionTypealready strips properties not present in all constituents. So this is probably a performance optimization and shouldn't simply be removed. Maybe we could stop after the first constituent that has no index signature.