-
Notifications
You must be signed in to change notification settings - Fork 58
Break out reexports by path #60
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
Conversation
This approach makes a lot of sense to me, esp. because it paves a path to eliminating these over time as (a) the root types align better with our needs and (b) we move as an ecosystem into strict mode. A question I had, here, though—based in part on my experimentation with Glint a couple weeks ago: what is the DX for go-to-definition, hover-docs, etc. on these? I think we end up showing the custom definition (and I don't actually see how we could do otherwise)? If so, have you given any thought to how we can make that experience better? There's a related question we'll want to solve around docs—you pointed out to me and @jamescdavis in Discord that copy-and-pasting something like the |
That's right, though it's possible to continue to trace the lineage from there to the actual source (the same way you have to with e.g. TypeScript in theory supports the Longer-term I'm still hopeful we can get back to a place where these reexports are unnecessary. There are essentially three things preventing us from just using declaration merging today:
Issue 1 will be hopefully be solved for Glimmer components by a forthcoming RFC. Issue 2 we can in principle solve whenever by updating DT, though I suspect it makes sense to wait for the component types RFC first to see how that shakes out. Issue 3 is slightly thornier, but there are well established patterns (used in the built-in DOM types, for instance) for making exported values type-augmentable. GlimmerX's export declare function on(
element: Element,
eventName: string,
callBack: EventListenerOrEventListenerObject,
options?: AddEventListenerOptions
): void; To: interface OnModifier {
(
element: Element,
eventName: string,
callBack: EventListenerOrEventListenerObject,
options?: AddEventListenerOptions
): void;
}
export declare const on: OnModifier; That would allow us to add an
I actually started poking at the git history for those doc comments yesterday, and it turns out they change very infrequently. My growing suspicion is that it's not likely to be a meaningfully higher maintenance burden to keep the docs up to date than it is to keep the type definitions themselves in sync. |
Going ahead and merging this since it doesn't make any of the issues you raised worse than the current status quo. |
This makes a lot of sense to me as well. It reminds me of the ember-decorators thing we all went through. |
While having a single entrypoint with all the reexports for an environment was convenient to implement, as I sat down to migrate my realworld-glimmerx-example-app repo over to the new glint API, it just didn't feel very good.
The proposed import scheme here aligns "normal" import paths 1:1 with glint import paths, allowing us to use exactly the same specifiers for each and making the transition in both directions smoother.
It also avoids triggering a type error if, for instance, you don't have
ember-modifier
installed in your app, since that import wouldn't trigger until you actually tried to import from@glint/environment-ember-loose/ember-modifier
.GlimmerX
@glimmerx/component
@glint/environment-glimmerx/component
@glimmerx/modifier
@glint/environment-glimmerx/modifier
@glimmerx/helper
@glint/environment-glimmerx/helper
Ember
@ember/component
@glint/environment-ember-loose/ember-component
@ember/component/helper
@glint/environment-ember-loose/ember-component/helper
@glimmer/component
@glint/environment-ember-loose/glimmer-component
ember-modifier
@glint/environment-ember-loose/ember-modifier