Fix bug when augmenting parent-less symbol (#28345)
This commit is contained in:
parent
4cb210ce2e
commit
f37101e871
5 changed files with 107 additions and 1 deletions
|
@ -26751,7 +26751,7 @@ namespace ts {
|
|||
let reportError = !(symbol.flags & SymbolFlags.Transient);
|
||||
if (!reportError) {
|
||||
// symbol should not originate in augmentation
|
||||
reportError = isExternalModuleAugmentation(symbol.parent!.declarations[0]);
|
||||
reportError = !!symbol.parent && isExternalModuleAugmentation(symbol.parent.declarations[0]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
31
tests/baselines/reference/moduleAugmentationOfAlias.js
Normal file
31
tests/baselines/reference/moduleAugmentationOfAlias.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
//// [tests/cases/compiler/moduleAugmentationOfAlias.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
interface I {}
|
||||
export default I;
|
||||
|
||||
//// [b.ts]
|
||||
export {};
|
||||
declare module './a' {
|
||||
export default interface I { x: number; }
|
||||
}
|
||||
|
||||
//// [c.ts]
|
||||
import I from "./a";
|
||||
function f(i: I) {
|
||||
i.x;
|
||||
}
|
||||
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
//// [c.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
function f(i) {
|
||||
i.x;
|
||||
}
|
32
tests/baselines/reference/moduleAugmentationOfAlias.symbols
Normal file
32
tests/baselines/reference/moduleAugmentationOfAlias.symbols
Normal file
|
@ -0,0 +1,32 @@
|
|||
=== /a.ts ===
|
||||
interface I {}
|
||||
>I : Symbol(I, Decl(a.ts, 0, 0), Decl(b.ts, 1, 22))
|
||||
|
||||
export default I;
|
||||
>I : Symbol(I, Decl(a.ts, 0, 0))
|
||||
|
||||
=== /b.ts ===
|
||||
export {};
|
||||
declare module './a' {
|
||||
>'./a' : Symbol("/a", Decl(a.ts, 0, 0), Decl(b.ts, 0, 10))
|
||||
|
||||
export default interface I { x: number; }
|
||||
>I : Symbol(I, Decl(a.ts, 0, 0), Decl(b.ts, 1, 22))
|
||||
>x : Symbol(I.x, Decl(b.ts, 2, 32))
|
||||
}
|
||||
|
||||
=== /c.ts ===
|
||||
import I from "./a";
|
||||
>I : Symbol(I, Decl(c.ts, 0, 6))
|
||||
|
||||
function f(i: I) {
|
||||
>f : Symbol(f, Decl(c.ts, 0, 20))
|
||||
>i : Symbol(i, Decl(c.ts, 1, 11))
|
||||
>I : Symbol(I, Decl(c.ts, 0, 6))
|
||||
|
||||
i.x;
|
||||
>i.x : Symbol(I.x, Decl(b.ts, 2, 32))
|
||||
>i : Symbol(i, Decl(c.ts, 1, 11))
|
||||
>x : Symbol(I.x, Decl(b.ts, 2, 32))
|
||||
}
|
||||
|
28
tests/baselines/reference/moduleAugmentationOfAlias.types
Normal file
28
tests/baselines/reference/moduleAugmentationOfAlias.types
Normal file
|
@ -0,0 +1,28 @@
|
|||
=== /a.ts ===
|
||||
interface I {}
|
||||
export default I;
|
||||
>I : I
|
||||
|
||||
=== /b.ts ===
|
||||
export {};
|
||||
declare module './a' {
|
||||
>'./a' : typeof import("/a")
|
||||
|
||||
export default interface I { x: number; }
|
||||
>x : number
|
||||
}
|
||||
|
||||
=== /c.ts ===
|
||||
import I from "./a";
|
||||
>I : any
|
||||
|
||||
function f(i: I) {
|
||||
>f : (i: I) => void
|
||||
>i : I
|
||||
|
||||
i.x;
|
||||
>i.x : number
|
||||
>i : I
|
||||
>x : number
|
||||
}
|
||||
|
15
tests/cases/compiler/moduleAugmentationOfAlias.ts
Normal file
15
tests/cases/compiler/moduleAugmentationOfAlias.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
// @Filename: /a.ts
|
||||
interface I {}
|
||||
export default I;
|
||||
|
||||
// @Filename: /b.ts
|
||||
export {};
|
||||
declare module './a' {
|
||||
export default interface I { x: number; }
|
||||
}
|
||||
|
||||
// @Filename: /c.ts
|
||||
import I from "./a";
|
||||
function f(i: I) {
|
||||
i.x;
|
||||
}
|
Loading…
Reference in a new issue