Skip to content

Fix bug when augmenting parent-less symbol #28345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 31 additions & 0 deletions tests/baselines/reference/moduleAugmentationOfAlias.js
Original file line number Diff line number Diff line change
@@ -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 changes: 32 additions & 0 deletions tests/baselines/reference/moduleAugmentationOfAlias.symbols
Original file line number Diff line number Diff line change
@@ -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 changes: 28 additions & 0 deletions tests/baselines/reference/moduleAugmentationOfAlias.types
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions tests/cases/compiler/moduleAugmentationOfAlias.ts
Original file line number Diff line number Diff line change
@@ -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;
}