Skip to content

Commit

Permalink
feat: ImportSpecifier and ExportSpecifier - Renamed .setAlias to .ren…
Browse files Browse the repository at this point in the history
…ameAlias

BREAKING CHANGE: .setAlias(...) is now .renameAlias(...).
  • Loading branch information
dsherret committed Sep 18, 2018
1 parent a7beb66 commit 0f446b6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/compiler/file/ExportSpecifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export class ExportSpecifier extends Node<ts.ExportSpecifier> {
}

/**
* Sets the alias for the name being exported.
* Sets the alias for the name being exported and renames all the usages.
* @param alias - Alias to set.
*/
setAlias(alias: string) {
renameAlias(alias: string) {
if (StringUtils.isNullOrWhitespace(alias)) {
this.removeAliasWithRename();
return this;
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/file/ImportSpecifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export class ImportSpecifier extends Node<ts.ImportSpecifier> {
}

/**
* Sets the alias for the name being imported.
* Sets the alias for the name being imported and renames all the usages.
* @param alias - Alias to set.
*/
setAlias(alias: string) {
renameAlias(alias: string) {
if (StringUtils.isNullOrWhitespace(alias)) {
this.removeAliasWithRename();
return this;
Expand Down
4 changes: 2 additions & 2 deletions src/tests/compiler/file/exportSpecifierTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ describe(nameof(ExportSpecifier), () => {
});
});

describe(nameof<ExportSpecifier>(n => n.setAlias), () => {
describe(nameof<ExportSpecifier>(n => n.renameAlias), () => {
function doTest(text: string, newAlias: string, expected: string, expectedImportName: string) {
const { sourceFile, project } = getInfoFromText<ExportDeclaration>(text);
const otherSourceFile = project.createSourceFile("file.ts", "export class name {}");
const importingFile = project.createSourceFile("importingFile.ts", `import { name } from './testFile';`);
const namedImport = sourceFile.getExportDeclarations()[0].getNamedExports()[0];
namedImport.setAlias(newAlias);
namedImport.renameAlias(newAlias);
expect(sourceFile.getText()).to.equal(expected);
expect(importingFile.getImportDeclarations()[0].getNamedImports()[0].getName()).to.equal(expectedImportName);
expect(otherSourceFile.getText()).to.equal("export class name {}");
Expand Down
4 changes: 2 additions & 2 deletions src/tests/compiler/file/importSpecifierTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ describe(nameof(ImportSpecifier), () => {
});
});

describe(nameof<ImportSpecifier>(n => n.setAlias), () => {
describe(nameof<ImportSpecifier>(n => n.renameAlias), () => {
function doTest(text: string, alias: string, expected: string) {
const {firstChild, sourceFile, project} = getInfoFromText<ImportDeclaration>(text);
const otherSourceFile = project.createSourceFile("file.ts", "export class name {}");
const namedImport = firstChild.getNamedImports()[0];
namedImport.setAlias(alias);
namedImport.renameAlias(alias);
expect(sourceFile.getText()).to.equal(expected);
expect(otherSourceFile.getText()).to.equal("export class name {}");
}
Expand Down

1 comment on commit 0f446b6

@dsherret
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For #425.

Please sign in to comment.