mathjs icon indicating copy to clipboard operation
mathjs copied to clipboard

Remove non-existing dependencies from index.d.ts

Open NilsDietrich opened this issue 5 months ago • 3 comments

Math.js provides the following dependencies from index.d.ts:

evalDependencies eyeDependencies typeofDependencies varDependencies

But they don't seem to exist in the bundle. Importing them causes errors like "Uncaught SyntaxError: The requested module '' does not provide an export named 'varDependencies'"

They should be removed. Or I'm missing something?

NilsDietrich avatar Jul 22 '25 15:07 NilsDietrich

That is a good point. The library is exported in different formats: CommonJS, ES Modules, and an UMD bundle. The bundle doesn't contain the dependencies like evalDependencies. So we can either include them in the bundle (that would increase the bundle size quite a bit), or export two different versions of the type definitions. I'm open to ideas.

josdejong avatar Jul 23 '25 12:07 josdejong

The bundle doesn't contain the dependencies like evalDependencies. So we can either include them in the bundle...

Im a little confused, what would we be including in the bundle? Shouldn't only whats defined by this library be exported in the Typescript type definition? Should this entire highlighted block exist at all? https://github.com/josdejong/mathjs/blob/e84ade64053e47f6118f137a7419fbeb1a23dad1/types/index.d.ts#L3753-L4083

gspetrou avatar Jul 28 '25 02:07 gspetrou

  • The ESM and CommonJS bundle are created from /src/index.js. This includes things like evaluateDependencies, coming from /src/entry/dependenciesAny.generated.js.
  • The UMD bundle is created from /src/defaultInstance.js, this excludes things like the dependencies objects to keep the bundle smaller.

josdejong avatar Jul 28 '25 08:07 josdejong