-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
Add "export"s to index.d.ts #3070
Comments
@kutoman my project is using types of FUI package without the need to Simply import like this to your import 'fomantic-ui'; //To use FUI types globally For your reference, my project structure looks like: app-folder
└───frontend
└───dist
└───node_modules
└───src
└───components
| app.svelte
| main.ts <= Right here!
└───...
| ... |
@KiddoV thx. That at least makes it possible to access the types via Just an example, to explain what I mean: import type { JQuery as FJQuery, JQueryStatic as FJQueryStatic } from "fomantic-ui";
export type ModuleType = keyof FJQuery;
export type StaticModuleType = keyof FJQueryStatic; but currently, I am forced to repeat and write down the interfaces from the fomantic ui |
the bigger issue is, when I do const moduleLoader = async (type: ModuleType) => import(`../../../semantic/dist/components/${type}.min.js`); and this works like a charm when I only import the types via |
@kutoman thanks for the explanation, FomanticUI heavily relies on For example, if the interfaces were exported, you might encounter issues like: // Property 'toast' does not exist on type 'JQuery<Document>'.ts(2339)
$(document).toast({
//...
});
// Property 'transition' does not exist on type 'JQuery<HTMLElement>'.ts(2339)
$(".main-msgbox").transition("shake", "200ms"); This problem arises because the exported interfaces disrupt the global nature of jQuery plugins. Remember, FUI is not a TypeScript-based ES6 module library; it relies on jQuery's global scope. (FomanticUI v3 will be different 🙂 ) If you want to create a library based on FUI, take a look at other libraries like svantic to see how they wrap FUI without the need to export those interfaces. |
@KiddoV ok I see, thanks for the detailed explanation! Such a coincidence , I am also working on a library for Svelte and therefore I've already checked Svantic. That's why I wanted to solve this in a more abstract way. I'll publish the repo on github, as soon as it has matured sufficiently. |
@kutoman, we would love to see your library go live, and it's great to see FUI grow along with other libraries based on it. Please do not hesitate to drop a link to your library here! |
@KiddoV yeah definetely, I will! just for those, who might be looking for a workaround here: import the FUI namespace this way: import type {} from "fomantic-ui"; this way the bundle semantic.js won't get loaded and you still can load the minified chunks of the modules individually. |
Feature Request
In the case of my project, in order to make use of the types from the fomantic-ui package the types from
index.d.ts
must be exported. I couldn't manage to get the types imported properly otherwise.Example (if possible)
The text was updated successfully, but these errors were encountered: