Fix a bug with reexport-all
The prior code wasn't extracting the member part of the token name when reexporting symbols, meaning the member was fully qualified. For example, when reexporting a class "C" from another module "other", the resulting name was "other:C". This is correct for the export node's token -- so it can be resolved correctly to its source -- however, clearly the identifier for the export should not contain the module part. This change strips it in the appropriate place.
This commit is contained in:
parent
ae8284e86e
commit
f226392051
|
@ -282,6 +282,15 @@ export class Transformer {
|
|||
return path;
|
||||
}
|
||||
|
||||
// extractMemberToken returns just the member part of a fully qualified token, leaving off the module part.
|
||||
private extractMemberToken(token: symbols.Token): symbols.Token {
|
||||
let sepIndex: number = token.indexOf(symbols.moduleSep);
|
||||
if (sepIndex !== -1) {
|
||||
token = token.substring(sepIndex+1);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
// resolveModuleSymbol binds either a name or a path to an associated module symbol.
|
||||
private resolveModuleSymbol(node: ts.Node, name?: string, path?: string): ts.Symbol {
|
||||
// Resolve the module name to a real symbol.
|
||||
|
@ -601,7 +610,7 @@ export class Transformer {
|
|||
kind: ast.exportKind,
|
||||
name: <ast.Identifier>{
|
||||
kind: ast.identifierKind,
|
||||
ident: name,
|
||||
ident: this.extractMemberToken(name),
|
||||
},
|
||||
token: name,
|
||||
});
|
||||
|
|
|
@ -188,27 +188,27 @@
|
|||
"ident": "index"
|
||||
},
|
||||
"members": {
|
||||
"other:C": {
|
||||
"C": {
|
||||
"kind": "Export",
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"ident": "other:C"
|
||||
"ident": "C"
|
||||
},
|
||||
"token": "other:C"
|
||||
},
|
||||
"other:I": {
|
||||
"I": {
|
||||
"kind": "Export",
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"ident": "other:I"
|
||||
"ident": "I"
|
||||
},
|
||||
"token": "other:I"
|
||||
},
|
||||
"other:v": {
|
||||
"v": {
|
||||
"kind": "Export",
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"ident": "other:v"
|
||||
"ident": "v"
|
||||
},
|
||||
"token": "other:v"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue