Skip to content

Commit

Permalink
fix: Getting symbol exports by name should call `ts.escapeLeadingUnde…
Browse files Browse the repository at this point in the history
…rscores` on the name.
  • Loading branch information
dsherret committed Nov 16, 2019
1 parent a8881d7 commit d2694ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/bootstrap/src/tests/projectTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ describe(nameof(Project), () => {
const program = project.createProgram();
const typeChecker = program.getTypeChecker();
const symbol = typeChecker.getSymbolAtLocation(sourceFile)!;
const tExport = symbol.exports!.get("t" as ts.__String)!;
const tExport = symbol.exports!.get(ts.escapeLeadingUnderscores("t"))!;
expect(tExport.getName()).to.equal("t");
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-morph/src/compiler/ast/common/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export class Node<NodeType extends ts.Node = ts.Node> {
if (locals == null)
return undefined;

const tsSymbol = locals.get(name as ts.__String);
const tsSymbol = locals.get(ts.escapeLeadingUnderscores(name));
return tsSymbol == null ? undefined : this._context.compilerFactory.getSymbol(tsSymbol);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/ts-morph/src/compiler/symbols/Symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class Symbol {
if (this.compilerSymbol.exports == null)
return undefined;

const tsSymbol = this.compilerSymbol.exports.get(name as ts.__String);
const tsSymbol = this.compilerSymbol.exports.get(ts.escapeLeadingUnderscores(name));
return tsSymbol == null ? undefined : this._context.compilerFactory.getSymbol(tsSymbol);
}

Expand Down Expand Up @@ -165,7 +165,7 @@ export class Symbol {
if (this.compilerSymbol.globalExports == null)
return undefined;

const tsSymbol = this.compilerSymbol.globalExports.get(name as ts.__String);
const tsSymbol = this.compilerSymbol.globalExports.get(ts.escapeLeadingUnderscores(name));
return tsSymbol == null ? undefined : this._context.compilerFactory.getSymbol(tsSymbol);
}

Expand Down Expand Up @@ -194,7 +194,7 @@ export class Symbol {
if (this.compilerSymbol.members == null)
return undefined;

const tsSymbol = this.compilerSymbol.members.get(name as ts.__String);
const tsSymbol = this.compilerSymbol.members.get(ts.escapeLeadingUnderscores(name));
return tsSymbol == null ? undefined : this._context.compilerFactory.getSymbol(tsSymbol);
}

Expand Down

0 comments on commit d2694ba

Please sign in to comment.