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 know that this repository is JavaScript by choice and I'm definitely not proposing to rewrite it in TypeScript. However, most modern IDEs leverage type definitions to show tooltips and hints even for developers using pure JavaScript. In the ideal case scenario, one doesn't even have to open the documentation, because they see everything in their editor:
The mathjs source code contains all the important information: the methods are strongly typed thanks to typed-function, every method has a jsDoc comment with complete specification attached to it. But currently, none of this information is exported as type definitions. For types we're dependent on DefinitelyTyped which has to be manually fixed every time a new version comes out, and is prone to misunderstanding and mistakes in transcribtion.
This code duplication is unfortunate and could be avoided. TypeScript supports generating type definitions from js files. If mathjs were just a traditional ES6 module, setting up type generation would be trivial. But since there appears to be some complicated interdependency between the files, it might be a bit trickier.
EDIT: I'm attaching a link to a string matching trick for TypeScript, so that I can find it here if I need it.
@josdejong I'm willing to invest some of my time to investigate this issue further, but I don't want to waste my time, so please let me know if you'd be interested in this.
Also, I'd like to ask, why does mathjs have a custom dependency loader (utils/factory.js). Aren't the already existing mechanisms of ES6 modules enough?
The text was updated successfully, but these errors were encountered:
So far we've chosen not to integrate TS type definitions inside the library itself, see #244. My main concern was having to maintain all these type definitions inside the library instead of keeping it just plain JS.
I do like your idea of automatically generating TypeScript definitions, if that is possible I think it's worth bundling the generated definitions in the library itself. It would be great if you could explore the possibilities Michal!
Also, I'd like to ask, why does mathjs have a custom dependency loader (utils/factory.js). Aren't the already existing mechanisms of ES6 modules enough?
The factory.js file is a mechanism for dependency injection, it is not about import/export.
I know that this repository is JavaScript by choice and I'm definitely not proposing to rewrite it in TypeScript. However, most modern IDEs leverage type definitions to show tooltips and hints even for developers using pure JavaScript. In the ideal case scenario, one doesn't even have to open the documentation, because they see everything in their editor:
The mathjs source code contains all the important information: the methods are strongly typed thanks to typed-function, every method has a jsDoc comment with complete specification attached to it. But currently, none of this information is exported as type definitions. For types we're dependent on DefinitelyTyped which has to be manually fixed every time a new version comes out, and is prone to misunderstanding and mistakes in transcribtion.
This code duplication is unfortunate and could be avoided. TypeScript supports generating type definitions from js files. If mathjs were just a traditional ES6 module, setting up type generation would be trivial. But since there appears to be some complicated interdependency between the files, it might be a bit trickier.
EDIT: I'm attaching a link to a string matching trick for TypeScript, so that I can find it here if I need it.
@josdejong I'm willing to invest some of my time to investigate this issue further, but I don't want to waste my time, so please let me know if you'd be interested in this.
Also, I'd like to ask, why does mathjs have a custom dependency loader (
utils/factory.js
). Aren't the already existing mechanisms of ES6 modules enough?The text was updated successfully, but these errors were encountered: