Closed NullVoxPopuli closed 10 months ago
Gonna close because I don't have a solution in mind.
Demo: https://stackblitz.com/edit/stackblitz-starters-cj9ass?file=README.md
Additional Context: https://discord.com/channels/480462759797063690/568935504288940056/1171853131521470534
Resolves: https://github.com/typed-ember/glint/issues/628
Given imports of:
emitted declarations created via
glint --declaration
contain:This is incorrect, as in order to make
greeting.gts
andgreeter.ts
valid imports in declarations, the following declaration files would need to exist:A goal is not just have Glint support gjs/gts imports, but have the emitted output of
glint --declarations
be compatible withtsc
.So, to do that, for
.gjs
and.gts
imports, we'll need to include.gjs
and.gts
in the name of the emitted assets.the old approach
So one way to deal with this is to, when transforming the files, chop off the extensions entirely so that the generated `index.d.ts` would contain: ```ts // index.d.ts import { Greeting } from './greeting'; import { greeter } from './greeter'; ``` which means that, the currently emitted `.d.ts`-only files would resolve... _if_ the resolving code is changed to support iterating over all possible file extensions -- which could lead to slower declaration building.background
using the learnings from work on the rollup plugins, it was _much_ easier to work with all the different files with explicit extensions in the imports. Resolving got _way_ easier, because the extensions were just right there in the import, and correct to what matched on disk. Unlike how TS has totally make extensions imports a nightmare for some projects, extension usage on `@embroider/addon-dev` _makes sense_ (specifying the author format, and it's compiled away in the resulting js). ----------- I think it'd be easier and less code to emit `basename(Support for resolving
gts
-extensioned files was added in: https://github.com/typed-ember/glint/pull/621 This PR finishes that work by making sure emitted declarations can resolve other declarations.