You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i noticed you're using pika for automatically building types. this is rad for the main checkboxland instance, but, when it comes to plugins those types are not inferred. since a plugin's js file does not export its internal functions, pika doesnt either.
for example, in print.js, if the print function is exported too
exportdefault{name: 'print',exec: print,
print // added this line}
THEN, i believe the output .d.ts file would look something like:
declarenamespace_default{exportconstname: string;export{printasexec};export{printasprint};// added this line}exportdefault_default;declarefunctionprint(text: any,options?: {}): any;
and THEN people using your lib in typescript could augment the main checkboxland class w plugins as needed, something like:
import{Checkboxland}from'checkboxland';importCblPluginPrintTypesfrom'../../node_modules/checkboxland/dist-types/plugins/print/print';// augmented typeCblPluggedIn=Checkboxland&typeofCblPluginPrintTypes;constcbl=newCheckboxland({ dimensions })asCblPluggedIn;cbl.print('words');// works correctly without ts errors
of course, there are other ways to correctly add plugin typings to the cbl class in typescript and maybe you have an idea for the builtin plugins, just offering one solution.
cheers
The text was updated successfully, but these errors were encountered:
Hey! Thanks for the heads up... it's a good callout.
I'd have to test this out but I think it's a good approach since the types would still be generated automatically (and that's something I'd want to preserve).
what a fun library! thanks @bryanbraun 👏
i noticed you're using pika for automatically building types. this is rad for the main checkboxland instance, but, when it comes to plugins those types are not inferred. since a plugin's js file does not export its internal functions, pika doesnt either.
for example, in
print.js
, if theprint
function is exported tooTHEN, i believe the output .d.ts file would look something like:
and THEN people using your lib in typescript could augment the main checkboxland class w plugins as needed, something like:
of course, there are other ways to correctly add plugin typings to the cbl class in typescript and maybe you have an idea for the builtin plugins, just offering one solution.
cheers
The text was updated successfully, but these errors were encountered: