Skip to content

Commit

Permalink
fix: #482 - Import and export declaration should not include quotes i…
Browse files Browse the repository at this point in the history
…n module specifier in structure
  • Loading branch information
cancerberoSgx authored and dsherret committed Oct 28, 2018
1 parent 5db4606 commit 92c7f46
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/compiler/ast/module/ExportDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export class ExportDeclaration extends ExportDeclarationBase<ts.ExportDeclaratio
getStructure(): ExportDeclarationStructure {
const moduleSpecifier = this.getModuleSpecifier();
return callBaseGetStructure<ExportDeclarationStructure>(ExportDeclarationBase.prototype, this, {
moduleSpecifier: moduleSpecifier ? moduleSpecifier.getText() : undefined,
moduleSpecifier: moduleSpecifier ? moduleSpecifier.getLiteralText() : undefined,
namedExports: this.getNamedExports().map(node => node.getStructure())
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/ast/module/ImportDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export class ImportDeclaration extends ImportDeclarationBase<ts.ImportDeclaratio

return callBaseGetStructure<ImportDeclarationStructure>(ImportDeclarationBase.prototype, this, {
defaultImport: defaultImport ? defaultImport.getText() : undefined,
moduleSpecifier: this.getModuleSpecifier().getText(),
moduleSpecifier: this.getModuleSpecifier().getLiteralText(),
namedImports: this.getNamedImports().map(node => node.getStructure()),
namespaceImport: namespaceImport ? namespaceImport.getText() : undefined
});
Expand Down
4 changes: 2 additions & 2 deletions src/tests/compiler/module/exportDeclarationTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,14 @@ describe(nameof(ExportDeclaration), () => {

it("should work with named export declarations", () => {
doTest(`export { name } from "./test";`, {
moduleSpecifier: '"./test"',
moduleSpecifier: './test',
namedExports: [{ alias: undefined, name: "name" }]
});
});

it("should work with namespace export declarations", () => {
doTest(`export * from "./test";`, {
moduleSpecifier: '"./test"',
moduleSpecifier: './test',
namedExports: []
});
});
Expand Down
8 changes: 4 additions & 4 deletions src/tests/compiler/module/importDeclarationTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ describe(nameof(ImportDeclaration), () => {
it("should work when has named imports", () => {
doTest(`import { a } from 'foo'`, {
defaultImport: undefined,
moduleSpecifier: "'foo'",
moduleSpecifier: "foo",
namedImports: [{ name: "a", alias: undefined }],
namespaceImport: undefined
});
Expand All @@ -689,7 +689,7 @@ describe(nameof(ImportDeclaration), () => {
it("should work when is a namespace import", () => {
doTest(`import * as ts from 'typescript'`, {
defaultImport: undefined,
moduleSpecifier: "\'typescript\'",
moduleSpecifier: "typescript",
namedImports: [],
namespaceImport: "ts"
});
Expand All @@ -698,7 +698,7 @@ describe(nameof(ImportDeclaration), () => {
it("should work for default imports", () => {
doTest(`import bar from 'foo'`, {
defaultImport: "bar",
moduleSpecifier: "\'foo\'",
moduleSpecifier: "foo",
namedImports: [],
namespaceImport: undefined
});
Expand All @@ -707,7 +707,7 @@ describe(nameof(ImportDeclaration), () => {
it("should work for default with named imports", () => {
doTest(`import bar, {test} from 'foo'`, {
defaultImport: "bar",
moduleSpecifier: "\'foo\'",
moduleSpecifier: "foo",
namedImports: [{ name: "test", alias: undefined }],
namespaceImport: undefined
});
Expand Down

0 comments on commit 92c7f46

Please sign in to comment.