Skip to content

Support export * #249

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

Closed
wants to merge 4 commits into from
Closed
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
1 change: 1 addition & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ under the licensing terms detailed in LICENSE:
* Norton Wang <[email protected]>
* Alan Pierce <[email protected]>
* Palmer <[email protected]>
* Andy Hanson <[email protected]>

Portions of this software are derived from third-party works licensed under
the following terms:
Expand Down
17 changes: 13 additions & 4 deletions src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,10 @@ export class ImportStatement extends Statement {
path: StringLiteralExpression;
/** Normalized path. */
normalizedPath: string;
/** Mangled internal path being referenced. */
/**
* Mangled internal path being referenced.
* Note: actual referenced path may be this + "/index". See `lookupSourceByPath` in `program.ts`.
*/
internalPath: string;
}

Expand Down Expand Up @@ -1972,9 +1975,15 @@ export function mangleInternalName(declaration: DeclarationStatement, asGlobal:
return mangleInternalName(<DeclarationStatement>parent, asGlobal) +
STATIC_DELIMITER + name;
}
return asGlobal
? name
: declaration.range.source.internalPath + PATH_DELIMITER + name;
return asGlobal ? name : getSourceLevelName(declaration.range.source, name);
}

export function getSourceLevelName({ internalPath }: Source, simpleName: string): string {
return getSourceLevelNameFromInternalPath(internalPath, simpleName);
}

export function getSourceLevelNameFromInternalPath(internalPath: string, simpleName: string): string {
return internalPath + PATH_DELIMITER + simpleName;
}

/** Mangles an external to an internal path. */
Expand Down
7 changes: 3 additions & 4 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ import {

nodeIsConstantValue,
isLastStatement,
findDecorator
findDecorator,
getSourceLevelName
} from "./ast";

import {
Expand Down Expand Up @@ -1266,9 +1267,7 @@ export class Compiler extends DiagnosticEmitter {
if (!members) return; // filespace
for (let i = 0, k = members.length; i < k; ++i) {
let member = members[i];
let element = fileLevelExports.get(
statement.range.source.internalPath + PATH_DELIMITER + member.externalName.text
);
let element = fileLevelExports.get(getSourceLevelName(statement.range.source, member.externalName.text));
if (!element) continue; // reported in Program#initialize
switch (element.kind) {
case ElementKind.CLASS_PROTOTYPE: {
Expand Down
2 changes: 2 additions & 0 deletions src/diagnosticMessages.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export enum DiagnosticCode {
Duplicate_identifier_0 = 2300,
Cannot_find_name_0 = 2304,
Module_0_has_no_exported_member_1 = 2305,
Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity = 2308,
Generic_type_0_requires_1_type_argument_s = 2314,
Type_0_is_not_generic = 2315,
Type_0_is_not_assignable_to_type_1 = 2322,
Expand Down Expand Up @@ -204,6 +205,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string {
case 2300: return "Duplicate identifier '{0}'.";
case 2304: return "Cannot find name '{0}'.";
case 2305: return "Module '{0}' has no exported member '{1}'.";
case 2308: return "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity.";
case 2314: return "Generic type '{0}' requires {1} type argument(s).";
case 2315: return "Type '{0}' is not generic.";
case 2322: return "Type '{0}' is not assignable to type '{1}'.";
Expand Down
1 change: 1 addition & 0 deletions src/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"Duplicate identifier '{0}'.": 2300,
"Cannot find name '{0}'.": 2304,
"Module '{0}' has no exported member '{1}'.": 2305,
"Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity.": 2308,
"Generic type '{0}' requires {1} type argument(s).": 2314,
"Type '{0}' is not generic.": 2315,
"Type '{0}' is not assignable to type '{1}'.": 2322,
Expand Down
Loading