Skip to content

Commit c5e0272

Browse files
committed
Deduplicate repeated declarations on union/intersection properties
1 parent 87aa917 commit c5e0272

32 files changed

+3101
-103
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15697,7 +15697,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1569715697
else if (prop.valueDeclaration && prop.valueDeclaration !== firstValueDeclaration) {
1569815698
hasNonUniformValueDeclaration = true;
1569915699
}
15700-
declarations = addRange(declarations, prop.declarations);
15700+
if (prop.declarations) {
15701+
for (const d of prop.declarations) {
15702+
declarations = appendIfUnique(declarations, d);
15703+
}
15704+
}
1570115705
const type = getTypeOfSymbol(prop);
1570215706
if (!firstType) {
1570315707
firstType = type;

tests/baselines/reference/arrayDestructuringInSwitch1.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ export function evaluate(expression: Expression): boolean {
3131

3232
case 'and': {
3333
return operands.every((child) => evaluate(child));
34-
>operands.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
34+
>operands.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
3535
>operands : Symbol(operands, Decl(arrayDestructuringInSwitch1.ts, 5, 20))
36-
>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
36+
>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
3737
>child : Symbol(child, Decl(arrayDestructuringInSwitch1.ts, 8, 31))
3838
>evaluate : Symbol(evaluate, Decl(arrayDestructuringInSwitch1.ts, 1, 84))
3939
>child : Symbol(child, Decl(arrayDestructuringInSwitch1.ts, 8, 31))

tests/baselines/reference/arraySlice.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var arr: string[] | number[];
55
>arr : Symbol(arr, Decl(arraySlice.ts, 0, 3))
66

77
arr.splice(1, 1);
8-
>arr.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
8+
>arr.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
99
>arr : Symbol(arr, Decl(arraySlice.ts, 0, 3))
10-
>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
10+
>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
1111

tests/baselines/reference/bestChoiceType.symbols

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
// Repro from #10041
55

66
(''.match(/ /) || []).map(s => s.toLowerCase());
7-
>(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
7+
>(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
88
>''.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
99
>match : Symbol(String.match, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
10-
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
10+
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
1111
>s : Symbol(s, Decl(bestChoiceType.ts, 2, 26))
1212
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
1313
>s : Symbol(s, Decl(bestChoiceType.ts, 2, 26))
@@ -29,9 +29,9 @@ function f1() {
2929

3030
let z = y.map(s => s.toLowerCase());
3131
>z : Symbol(z, Decl(bestChoiceType.ts, 9, 7))
32-
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
32+
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
3333
>y : Symbol(y, Decl(bestChoiceType.ts, 8, 7))
34-
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
34+
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
3535
>s : Symbol(s, Decl(bestChoiceType.ts, 9, 18))
3636
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
3737
>s : Symbol(s, Decl(bestChoiceType.ts, 9, 18))
@@ -53,9 +53,9 @@ function f2() {
5353

5454
let z = y.map(s => s.toLowerCase());
5555
>z : Symbol(z, Decl(bestChoiceType.ts, 15, 7))
56-
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
56+
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
5757
>y : Symbol(y, Decl(bestChoiceType.ts, 14, 7))
58-
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
58+
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
5959
>s : Symbol(s, Decl(bestChoiceType.ts, 15, 18))
6060
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
6161
>s : Symbol(s, Decl(bestChoiceType.ts, 15, 18))

tests/baselines/reference/bivariantInferences.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ declare const b: (string | number)[] | null[] | undefined[] | {}[];
2626

2727
let x = a.equalsShallow(b);
2828
>x : Symbol(x, Decl(bivariantInferences.ts, 9, 3))
29-
>a.equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20))
29+
>a.equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20))
3030
>a : Symbol(a, Decl(bivariantInferences.ts, 6, 13))
31-
>equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20))
31+
>equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20))
3232
>b : Symbol(b, Decl(bivariantInferences.ts, 7, 13))
3333

tests/baselines/reference/callsOnComplexSignatures.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ function test3(items: string[] | number[]) {
9696
>items : Symbol(items, Decl(callsOnComplexSignatures.tsx, 36, 15))
9797

9898
items.forEach(item => console.log(item));
99-
>items.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
99+
>items.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
100100
>items : Symbol(items, Decl(callsOnComplexSignatures.tsx, 36, 15))
101-
>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
101+
>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
102102
>item : Symbol(item, Decl(callsOnComplexSignatures.tsx, 37, 18))
103103
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
104104
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))

tests/baselines/reference/contextualOverloadListFromArrayUnion.symbols

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ declare const y: never[] | string[];
66

77
export const yThen = y.map(item => item.length);
88
>yThen : Symbol(yThen, Decl(one.ts, 1, 12))
9-
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
9+
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
1010
>y : Symbol(y, Decl(one.ts, 0, 13))
11-
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
11+
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
1212
>item : Symbol(item, Decl(one.ts, 1, 27))
1313
>item.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
1414
>item : Symbol(item, Decl(one.ts, 1, 27))
@@ -20,9 +20,9 @@ declare const y: number[][] | string[];
2020

2121
export const yThen = y.map(item => item.length);
2222
>yThen : Symbol(yThen, Decl(two.ts, 1, 12))
23-
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
23+
>y.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
2424
>y : Symbol(y, Decl(two.ts, 0, 13))
25-
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
25+
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
2626
>item : Symbol(item, Decl(two.ts, 1, 27))
2727
>item.length : Symbol(length, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
2828
>item : Symbol(item, Decl(two.ts, 1, 27))

tests/baselines/reference/controlFlowArrayErrors.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ function f6() {
123123
>x : Symbol(x, Decl(controlFlowArrayErrors.ts, 37, 7))
124124

125125
x.push(99); // Error
126-
>x.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
126+
>x.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
127127
>x : Symbol(x, Decl(controlFlowArrayErrors.ts, 37, 7))
128-
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
128+
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
129129
}
130130

131131
function f7() {

0 commit comments

Comments
 (0)