Replies: 7 comments 8 replies
-
We can start from improving those: Converting to es modules is a whole new journey that has less impact and for me has very low priority. |
Beta Was this translation helpful? Give feedback.
-
could we take the typedef in the types library, fix it, and update it regularly? |
Beta Was this translation helpful? Give feedback.
-
i hope there was some kind of static analyzer of jsdocs, if jsdocs can create a full website from the doc notations it can also write a typedef file. I hoped someone created the template for it |
Beta Was this translation helpful? Give feedback.
-
Okay! I just needed to sleep on it :) See TypeScript Playground Example The IIFEs will have to assign their content like so fabric.util.animateColor = (function() {
// omitted
return animateColor;
})(); I was able to generate the following declare namespace fabric {
const version: string;
namespace util {
/**
* Changes the color from one to another within certain period of time, invoking callbacks as value is being changed.
* @memberOf fabric.util
* @param {String} fromColor The starting color in hex or rgb(a) format.
* @param {String} toColor The starting color in hex or rgb(a) format.
* @param {Number} [duration] Duration of change (in ms).
* @param {Object} [options] Animation options
* @param {Function} [options.onChange] Callback; invoked on every value change
* @param {Function} [options.onComplete] Callback; invoked when value change is completed
* @param {Function} [options.colorEasing] Easing function. Note that this function only take two arguments (currentTime, duration). Thus the regular animation easing functions cannot be used.
* @param {Function} [options.abort] Additional function with logic. If returns true, onComplete is called.
*/
function animateColor(fromColor: string, toColor: string, duration?: number, options?: {
onChange?: Function;
onComplete?: Function;
colorEasing?: Function;
abort?: Function;
}): void;
}
} |
Beta Was this translation helpful? Give feedback.
-
I think this approach is a killer, going around instead of simply getting it done. |
Beta Was this translation helpful? Give feedback.
-
If you want to move on on this, we need someone that pick up an existiing t.ds file, delete the wrong parts that are not compatible with 4.5.0 and commits it. |
Beta Was this translation helpful? Give feedback.
-
What would it take to generate typescript definitions (d.ts) for fabric.js? (#6763 (comment))
According to https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html it looks simple. But after trying it out the d.ts file is empty. I believe it's because fabric.js is written in the IIFE style.
Does anyone know if IIFEs can be made to work?
Alternatively the code base could be converted to ES Module. But that's extra work and it might break stuff.
Beta Was this translation helpful? Give feedback.
All reactions