Skip to content

Commit

Permalink
Merge pull request #11 from bertdeblock/support-inline-imports
Browse files Browse the repository at this point in the history
Support inline imports
  • Loading branch information
NullVoxPopuli committed Mar 19, 2024
2 parents b6c7cd9 + 8a69f53 commit a2cd103
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/fixes/glint.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export function fixGTSExtensions(contents) {
path.node.source.value = path.node.source.value.replace(/\.gts$/, '');
});

root
.find(j.TSImportType)
.filter((path) => path.node.argument.value.includes('.gts'))
.forEach((path) => {
path.node.argument.value = path.node.argument.value.replace(/\.gts$/, '');
});

return root.toSource();
}

Expand Down
12 changes: 12 additions & 0 deletions src/fixes/glint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ describe('fixGTSExtensions', () => {

expect(result).toBe(`export { x } from "./foo";`);
});

test('works on inline imports', () => {
let code = stripIndent`
import("@ember/component/template-only").TOC<import("./foo.gts").FooSignature>;
`;

let result = fixGTSExtensions(code);

expect(result).toBe(
`import("@ember/component/template-only").TOC<import("./foo").FooSignature>;`
);
});
});

describe('fixOwnReferences', () => {
Expand Down

0 comments on commit a2cd103

Please sign in to comment.