Merge branch 'allow-export-specifier-reference' of https://github.com/Kovensky/TypeScript into Kovensky-allow-export-specifier-reference

This commit is contained in:
Nathan Shively-Sanders 2017-04-17 13:59:58 -07:00
commit 0292f5867c
5 changed files with 62 additions and 3 deletions

View file

@ -760,9 +760,15 @@ namespace ts {
// declaration is after usage, but it can still be legal if usage is deferred:
// 1. inside a function
// 2. inside an instance property initializer, a reference to a non-instance property
// 3. inside a static property initializer, a reference to a static method in the same class
// 1. inside an export specifier
// 2. inside a function
// 3. inside an instance property initializer, a reference to a non-instance property
// 4. inside a static property initializer, a reference to a static method in the same class
if (usage.parent.kind === SyntaxKind.ExportSpecifier) {
// export specifiers do not use the variable, they only make it available for use
return true;
}
const container = getEnclosingBlockScopeContainer(declaration);
return isUsedInFunctionOrInstanceProperty(usage, declaration, container);

View file

@ -0,0 +1,19 @@
//// [exportBinding.ts]
export { x }
const x = 'x'
export { Y as Z }
class Y {}
//// [exportBinding.js]
"use strict";
exports.__esModule = true;
var x = 'x';
exports.x = x;
var Y = (function () {
function Y() {
}
return Y;
}());
exports.Z = Y;

View file

@ -0,0 +1,14 @@
=== tests/cases/conformance/es6/modules/exportBinding.ts ===
export { x }
>x : Symbol(x, Decl(exportBinding.ts, 0, 8))
const x = 'x'
>x : Symbol(x, Decl(exportBinding.ts, 1, 5))
export { Y as Z }
>Y : Symbol(Z, Decl(exportBinding.ts, 3, 8))
>Z : Symbol(Z, Decl(exportBinding.ts, 3, 8))
class Y {}
>Y : Symbol(Y, Decl(exportBinding.ts, 3, 17))

View file

@ -0,0 +1,15 @@
=== tests/cases/conformance/es6/modules/exportBinding.ts ===
export { x }
>x : "x"
const x = 'x'
>x : "x"
>'x' : "x"
export { Y as Z }
>Y : typeof Y
>Z : typeof Y
class Y {}
>Y : Y

View file

@ -0,0 +1,5 @@
export { x }
const x = 'x'
export { Y as Z }
class Y {}