typed-ember / glint

TypeScript powered tooling for Glimmer templates
https://typed-ember.gitbook.io/glint
MIT License
109 stars 51 forks source link

Make explicit extensions in imports work. #659

Open NullVoxPopuli opened 9 months ago

NullVoxPopuli commented 9 months ago

Resolves https://github.com/typed-ember/glint/issues/628

See repro repo: https://stackblitz.com/edit/stackblitz-starters-g58nhp?file=examples%2Fts-addon-node16%2Fpackage.json,examples%2Fts-addon-node16%2Fsrc%2Findex.ts

Using the patch from here: https://github.com/typed-ember/glint/issues/628#issuecomment-1805416937 (where TS would allow)

And the test from here: https://github.com/typed-ember/glint/pull/648/files#diff-a835cb215198fc0a50973a4ae3bf66eac5a4b0bc21293fa29fc70888d663f797

The downside to this approach is "what if" someone has a foo.gts.ts file (probably co-located with a foo.gts.hbs file) -- but like, realistically, this isn't a thing they can use unless they're going half-in on static component references.

Notes:

Testing locally

The Glint Terminal

Repro Terminal


note that after every pnpm link, in order to work in the glint repo again, you'll need to re-run yarn, and un-delete the glint-monorepo-test-utils package.

lifeart commented 8 months ago

Wondering, is allowArbitraryExtensions may help us here? https://www.typescriptlang.org/tsconfig#allowArbitraryExtensions Also, looks like we may have customConditions https://www.typescriptlang.org/tsconfig#customConditions dynamically generated

Interesting part: {file basename}.d.{extension}.ts - is proposed type definition for custom extensions, so, instead of having component.gts.d.ts we may need to use component.d.gts.ts

image image

https://github.com/microsoft/TypeScript/issues/50133

NullVoxPopuli commented 8 months ago

@lifeart yeah, that sounds like a reasonable feature -- but we'd still need glint to to remove the extension during emitting.

So far, I've found it easiest, to work around the problem :( Not ideal, but I don't know what the correct fix is yet. Maybe it's what you link to!