From 4fdb687f878fe7cc96cb15832ea25bfd40df0991 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Tue, 19 Mar 2024 21:48:11 -0400 Subject: [PATCH 1/2] Support export * for https://github.com/typed-ember/glint/issues/628 --- src/fixes/glint.js | 10 ++++++++++ src/fixes/glint.test.ts | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/fixes/glint.js b/src/fixes/glint.js index 1a8a5a9..269eb7b 100644 --- a/src/fixes/glint.js +++ b/src/fixes/glint.js @@ -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')) + .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(); } diff --git a/src/fixes/glint.test.ts b/src/fixes/glint.test.ts index 354939f..443da83 100644 --- a/src/fixes/glint.test.ts +++ b/src/fixes/glint.test.ts @@ -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; From d89ffa53147af72f781f3f1bc434392164206e8f Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Tue, 19 Mar 2024 21:52:07 -0400 Subject: [PATCH 2/2] eh --- src/fixes/glint.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fixes/glint.js b/src/fixes/glint.js index 269eb7b..f9c987c 100644 --- a/src/fixes/glint.js +++ b/src/fixes/glint.js @@ -41,6 +41,8 @@ export function fixGTSExtensions(contents) { 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