Skip to content

Commit

Permalink
Merge pull request #13 from NullVoxPopuli/handle-export-star
Browse files Browse the repository at this point in the history
Support export * for typed-ember/glint#628
  • Loading branch information
NullVoxPopuli authored Mar 20, 2024
2 parents e4e942a + d89ffa5 commit a690e6d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/fixes/glint.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ export function fixGTSExtensions(contents) {
path.node.argument.value = path.node.argument.value.replace(/\.gts$/, '');
});

root
.find(j.ExportAllDeclaration)
// TODO: can this really be a non-string?
// @ts-expect-error
.filter((path) => path.node.source?.value?.includes('.gts'))
.forEach((path) => {
// TODO: this may only be appropriate when
// moduleResolution = "bundler"
// @ts-expect-error
path.node.source.value = path.node.source.value.replace(/\.gts$/, '');
});

return root.toSource();
}

Expand Down
8 changes: 8 additions & 0 deletions src/fixes/glint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ describe('fixGTSExtensions', () => {
expect(result).toBe(`export { x } from "./foo";`);
});

test('works on export star', () => {
let code = `export * from './component.gts';`;

let result = fixGTSExtensions(code);

expect(result).toBe(`export * from "./component";`);
});

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

0 comments on commit a690e6d

Please sign in to comment.