When unidirectionally merging symbols, do so recursively
This commit is contained in:
parent
d69f9f3328
commit
973c3cac8d
|
@ -918,11 +918,12 @@ namespace ts {
|
||||||
addRange(target.declarations, source.declarations);
|
addRange(target.declarations, source.declarations);
|
||||||
if (source.members) {
|
if (source.members) {
|
||||||
if (!target.members) target.members = createSymbolTable();
|
if (!target.members) target.members = createSymbolTable();
|
||||||
mergeSymbolTable(target.members, source.members);
|
mergeSymbolTable(target.members, source.members, unidirectional);
|
||||||
}
|
}
|
||||||
if (source.exports) {
|
if (source.exports) {
|
||||||
if (!target.exports) target.exports = createSymbolTable();
|
if (!target.exports) target.exports = createSymbolTable();
|
||||||
mergeSymbolTable(target.exports, source.exports);
|
mergeSymbolTable(target.exports, source.exports, unidirectional
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!unidirectional) {
|
if (!unidirectional) {
|
||||||
recordMergedSymbol(target, source);
|
recordMergedSymbol(target, source);
|
||||||
|
@ -993,10 +994,10 @@ namespace ts {
|
||||||
return combined;
|
return combined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mergeSymbolTable(target: SymbolTable, source: SymbolTable) {
|
function mergeSymbolTable(target: SymbolTable, source: SymbolTable, unidirectional = false) {
|
||||||
source.forEach((sourceSymbol, id) => {
|
source.forEach((sourceSymbol, id) => {
|
||||||
const targetSymbol = target.get(id);
|
const targetSymbol = target.get(id);
|
||||||
target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol) : sourceSymbol);
|
target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
tests/cases/conformance/ambient/test.ts(6,6): error TS2339: Property 'a' does not exist on type 'OhNo'.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/conformance/ambient/types.ts (0 errors) ====
|
||||||
|
declare module "*.foo" {
|
||||||
|
export interface OhNo { star: string }
|
||||||
|
}
|
||||||
|
|
||||||
|
==== tests/cases/conformance/ambient/test.ts (1 errors) ====
|
||||||
|
declare module "a.foo" {
|
||||||
|
export interface OhNo { a: string }
|
||||||
|
}
|
||||||
|
import { OhNo } from "b.foo"
|
||||||
|
declare let ohno: OhNo;
|
||||||
|
ohno.a // oh no
|
||||||
|
~
|
||||||
|
!!! error TS2339: Property 'a' does not exist on type 'OhNo'.
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
//// [tests/cases/conformance/ambient/ambientDeclarationsPatterns_merging3.ts] ////
|
||||||
|
|
||||||
|
//// [types.ts]
|
||||||
|
declare module "*.foo" {
|
||||||
|
export interface OhNo { star: string }
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [test.ts]
|
||||||
|
declare module "a.foo" {
|
||||||
|
export interface OhNo { a: string }
|
||||||
|
}
|
||||||
|
import { OhNo } from "b.foo"
|
||||||
|
declare let ohno: OhNo;
|
||||||
|
ohno.a // oh no
|
||||||
|
|
||||||
|
|
||||||
|
//// [types.js]
|
||||||
|
//// [test.js]
|
||||||
|
"use strict";
|
||||||
|
exports.__esModule = true;
|
||||||
|
ohno.a; // oh no
|
|
@ -0,0 +1,27 @@
|
||||||
|
=== tests/cases/conformance/ambient/types.ts ===
|
||||||
|
declare module "*.foo" {
|
||||||
|
>"*.foo" : Symbol("*.foo", Decl(types.ts, 0, 0))
|
||||||
|
|
||||||
|
export interface OhNo { star: string }
|
||||||
|
>OhNo : Symbol(OhNo, Decl(types.ts, 0, 24))
|
||||||
|
>star : Symbol(OhNo.star, Decl(types.ts, 1, 25))
|
||||||
|
}
|
||||||
|
|
||||||
|
=== tests/cases/conformance/ambient/test.ts ===
|
||||||
|
declare module "a.foo" {
|
||||||
|
>"a.foo" : Symbol("a.foo", Decl(test.ts, 0, 0), Decl(types.ts, 0, 0))
|
||||||
|
|
||||||
|
export interface OhNo { a: string }
|
||||||
|
>OhNo : Symbol(OhNo, Decl(test.ts, 0, 24), Decl(types.ts, 0, 24))
|
||||||
|
>a : Symbol(OhNo.a, Decl(test.ts, 1, 25))
|
||||||
|
}
|
||||||
|
import { OhNo } from "b.foo"
|
||||||
|
>OhNo : Symbol(OhNo, Decl(test.ts, 3, 8))
|
||||||
|
|
||||||
|
declare let ohno: OhNo;
|
||||||
|
>ohno : Symbol(ohno, Decl(test.ts, 4, 11))
|
||||||
|
>OhNo : Symbol(OhNo, Decl(test.ts, 3, 8))
|
||||||
|
|
||||||
|
ohno.a // oh no
|
||||||
|
>ohno : Symbol(ohno, Decl(test.ts, 4, 11))
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
=== tests/cases/conformance/ambient/types.ts ===
|
||||||
|
declare module "*.foo" {
|
||||||
|
>"*.foo" : typeof import("*.foo")
|
||||||
|
|
||||||
|
export interface OhNo { star: string }
|
||||||
|
>star : string
|
||||||
|
}
|
||||||
|
|
||||||
|
=== tests/cases/conformance/ambient/test.ts ===
|
||||||
|
declare module "a.foo" {
|
||||||
|
>"a.foo" : typeof import("a.foo")
|
||||||
|
|
||||||
|
export interface OhNo { a: string }
|
||||||
|
>a : string
|
||||||
|
}
|
||||||
|
import { OhNo } from "b.foo"
|
||||||
|
>OhNo : any
|
||||||
|
|
||||||
|
declare let ohno: OhNo;
|
||||||
|
>ohno : OhNo
|
||||||
|
|
||||||
|
ohno.a // oh no
|
||||||
|
>ohno.a : any
|
||||||
|
>ohno : OhNo
|
||||||
|
>a : any
|
||||||
|
|
Loading…
Reference in a new issue