Hi! I want to add some functionality to my components with TypeScript. Something like open a modal dialog on the page.
In Version 6.X I did this by adding a decorator to my Story and use it like so:
export const loadScript = (StoryFn, context) => {
const scriptUrl = "/frontend/js/index.js";
const script = document.createElement("script");
script.src = scriptUrl;
script.async = true;
script.onload = () => {
console.log("Script loaded");
};
script.onerror = () => {
console.error("Script failed to load");
};
document.body.appendChild(script);
return StoryFn(context);
};
This works with precompiled JS code. But how do I add TypeScript to my Stories?
There is a lack of documentation for using StoryBook without any Framework.