Skip to content

Commit

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

root
.find(j.ExportAllDeclaration)
.filter((path) => path.node.source?.value?.includes('.gts'))

Check failure on line 44 in src/fixes/glint.js

View workflow job for this annotation

GitHub Actions / Test

Property 'includes' does not exist on type 'string | number | boolean | RegExp'.

Check failure on line 44 in src/fixes/glint.js

View workflow job for this annotation

GitHub Actions / Lint

Property 'includes' does not exist on type 'string | number | boolean | RegExp'.
.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 4fdb687

Please sign in to comment.