-
-
Notifications
You must be signed in to change notification settings - Fork 647
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
Simplify dist to only include one TS file #2871
Conversation
With this the exported types now matches what is actually exported in js. There is just one thing, that is weird. Right now, there is no type exported for const tour: InstanceType<typeof Shepherd.Tour> = new Shepherd.Tour(); I guess the easiest solution would be to use the namespaces again in the import _Step from './step';
import _Tour from './tour';
declare namespace Shepherd {
/**
* The currently active tour instance
*/
export const activeTour: _Tour | undefined;
export import Step = _Step;
export import Tour = _Tour;
}
export default Shepherd; |
@spike-rabbit I guess I just don't understand why either not just allowing the implicit types to be fine or to do as you suggested |
If you want to discuss more, perhaps either an example in codesandbox or join the discord could help? https://discord.gg/wdEBJ5Pt |
thx for the invite. Technical wise, with this change everything is fine. It is just for a developer not ideal. One sometimes need explicit types. In my case it is an explicit function return type, enforced by a linter. The v11 approach was nicer, as Anyway, I guess it is up to you whether you want to provide this. Apart from this, shepherd works pretty well for us, so thx for the nice library. |
@spike-rabbit we are at the mercy of tools that generate the declaration files for us. Because we use svelte, we cannot just run tsc and so this output was the best I have been able to get so far. We could import a bunch of these things into the |
@spike-rabbit I added more exports, can you please try this again? |
I like that the But the declaration is not ideal here. For instance tour is declared as a class: declare class Tour extends Evented {
...
} Which would allow consumers to do:
but this does not work, as the mjs does not export I see two options which I was also able to integrate in this PR:
type TourType = Tour;
export type { TourType as Tour}; That way consumers would not be able to call
constructor() {
if (typeof window === 'undefined') {
return new TourNoOp();
}
...
} Then you could just export export * from './evented.ts';
export * from './step.ts';
export * from './tour.ts'; |
@spike-rabbit we have tried several times to move the If you move it like you suggested into
Perhaps I am just not informed enough into how to make this work, but I don't think it will work since we are importing tour. Perhaps if we renamed it as you are suggesting, but I don't like it having a different name. |
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.
No description provided.