-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix support for gts extensions remaining in emitted declarations #648
Fix support for gts extensions remaining in emitted declarations #648
Conversation
const rewritten = rewriteModule(ts, { script: source }, glimmerxEnvironment)!; | ||
let rewritten; | ||
|
||
beforeEach(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without these changes, debugging was super troll time
'barrel.ts': stripIndent` | ||
export { default as Greeting } from './Greeting.gts'; | ||
export { Greeting as Greeting2 } from './re-export.gts'; | ||
export { two } from './vanilla.ts'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the declarations for this are, at present, emitted as ./vanilla.ts
, which is wrong.
To fix, either needs to happen:
- remove the
.ts
extension sovanilla.d.ts
matches with the emitted correspondingvanilla.js
- or emit a goofy
vanilla.ts.d.ts
file, along the same lines as what I suggested originally with emittingGreeting.gts.d.ts
This PR is currently going the way of removing all extensions.
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: #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: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(<import specifier>).d.ts
for every import, than to(which would def be a breaking change without a flag to opt in to this behavior)
Support for resolving
gts
-extensioned files was added in: #621This PR finishes that work by making sure emitted declarations can resolve other declarations.