glint: Import of .gts emits broken declarations
As reported on Discord, there seems to be a bug when having an import with an explicit .gts extension and running glint --declaration.
Reproduction:
- go to https://stackblitz.com/edit/github-yl7xy1
cd packages/accordionpnpm build- in
packages/accordion/declarations/components/accordion.d.tsyou can see an import ofitem.gts, which does not resolve, as there is only anitem.d.ts, which TS/Glint does not see as the declaration that matches this import apparently:
The emitted declarations can be fixed by patching manually, either
- by changing the import to be extension-less
- or by renaming
item.d.tstoitem.gts.d.ts
So I think glint --declaration should be doing either of these.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 18 (16 by maintainers)
Commits related to this issue
- Reproduce issue for https://github.com/typed-ember/glint/issues/628 — committed to NullVoxPopuli/glint by NullVoxPopuli 3 years ago
- Support export * for https://github.com/typed-ember/glint/issues/628 — committed to NullVoxPopuli/fix-bad-declaration-output by NullVoxPopuli 3 years ago
- Merge pull request #13 from NullVoxPopuli/handle-export-star Support export * for https://github.com/typed-ember/glint/issues/628 — committed to NullVoxPopuli/fix-bad-declaration-output by NullVoxPopuli 3 years ago
- Add rollup declarations plugin This invokes glint as a rollup plugin, and contains a workaround for broken gts imports, see https://github.com/typed-ember/glint/issues/628 — committed to embroider-build/embroider by simonihmig 2 years ago
- Add rollup declarations plugin This invokes glint as a rollup plugin, and contains a workaround for broken gts imports, see https://github.com/typed-ember/glint/issues/628 — committed to embroider-build/embroider by simonihmig 2 years ago
- Add rollup declarations plugin This invokes glint as a rollup plugin, and contains a workaround for broken gts imports, see https://github.com/typed-ember/glint/issues/628 — committed to embroider-build/embroider by simonihmig 2 years ago
- Add rollup declarations plugin This invokes glint as a rollup plugin, and contains a workaround for broken gts imports, see https://github.com/typed-ember/glint/issues/628 — committed to embroider-build/embroider by simonihmig 2 years ago
FYI as a byproduct of volar-izing glint, the declaration files emitted for
basename.gtsare nowbasename.gts.d.ts. This is in line with how Vue and others do it, and should serve as a solution to this issue, though it will likely be a breaking change for certain apps. We’re moving forward with this as a solution, and depending on a number of factors, we may decide to introduce a config or mitigating solution at some point in the future if this change is too much.I’ll let someone else decide if this is worth closing, but at this point the change to
.gts.d.tshas already been merged.Would be better to fix the root cause of course, but I don’t need to tell you that, and I also have no time and skills to get this fixed upstream 😕
But for end users, the plan is to land this as part of https://github.com/embroider-build/embroider/pull/1798, right?
Not sure if useful for others, but I’m using this simple workaround for now:
Patch writeFile to search/replace .gts to .ts