Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the TypeScript definitions of functions like number, bignumber, boolean, and complex returning an array/matrix with known type of values #2944

Open
brunoSnoww opened this issue Apr 26, 2023 · 3 comments

Comments

@brunoSnoww
Copy link
Contributor

Currently the typescript definitions for Arrays and Matrices only supports number, BigNumber,Fraction or Complex

  type MathNumericType = number | BigNumber | Fraction | Complex
  type MathArray = MathNumericType[] | MathNumericType[][]
  type MathCollection = MathArray | Matrix

But there are functions, like 'number', that process Arrays with non-numeric types, but which are considered wrong by Typescript:

let m = [true,false,'1','2','3']

//type error
let toNumber = math.chain(m).number().done() // [ 1, 0, 1, 2, 3 ]

Maybe adding a generic matrix/array type should solve ?

@josdejong
Copy link
Owner

Thanks for bringing this up.

Yes I think we can improve the TypeScript definitions of functions like number, bignumber, boolean, and complex in this regard, good point.

Anyone able to help improve the definitions of these functions?

@josdejong josdejong changed the title Create a generic Matrix type Improve the TypeScript definitions of functions like number, bignumber, boolean, and complex returning an array/matrix with known type of values May 15, 2023
@akdev2000
Copy link

akdev2000 commented Nov 14, 2023

Hi Josedejong,
Is this feature still needed? If yes, I can help.

@josdejong
Copy link
Owner

Yes indeed, thanks for your offer @akdev2000!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants