Skip to content

Commit

Permalink
Merge pull request #30719 from andrewbranch/bug/30668
Browse files Browse the repository at this point in the history
Fix crash when binding deep module.exports assignment
  • Loading branch information
andrewbranch committed Apr 3, 2019
2 parents 3f3444b + 85135c3 commit fed46ea
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2710,8 +2710,7 @@ namespace ts {
}
else {
const s = forEachIdentifierInEntityName(e.expression, parent, action);
if (!s || !s.exports) return Debug.fail();
return action(e.name, s.exports.get(e.name.escapedText), s);
return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests/cases/compiler/a.js(1,9): error TS2339: Property 'a' does not exist on type 'typeof import("tests/cases/compiler/a")'.


==== tests/cases/compiler/a.js (1 errors) ====
exports.a.b.c = 0;
~
!!! error TS2339: Property 'a' does not exist on type 'typeof import("tests/cases/compiler/a")'.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=== tests/cases/compiler/a.js ===
exports.a.b.c = 0;
>exports : Symbol("tests/cases/compiler/a", Decl(a.js, 0, 0))

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
=== tests/cases/compiler/a.js ===
exports.a.b.c = 0;
>exports.a.b.c = 0 : 0
>exports.a.b.c : any
>exports.a.b : any
>exports.a : any
>exports : typeof import("tests/cases/compiler/a")
>a : any
>b : any
>c : any
>0 : 0

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @allowJs: true
// @noEmit: true
// @checkJs: true
// @filename: a.js

exports.a.b.c = 0;

0 comments on commit fed46ea

Please sign in to comment.