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

fraction methods are not typed #3317

Closed
yukulele opened this issue Nov 16, 2024 · 4 comments · Fixed by #3330
Closed

fraction methods are not typed #3317

yukulele opened this issue Nov 16, 2024 · 4 comments · Fixed by #3330

Comments

@yukulele
Copy link
Contributor

Describe the bug
Fraction type only exposes s, n add d properties

mathjs/types/index.d.ts:4018:

export interface Fraction {
  s: number
  n: number
  d: number
}

so we can't use methods

To Reproduce

math.fraction('1.5').toFraction() // "3/2"
> tsc
error TS2339: Property 'toFraction' does not exist on type 'Fraction'.

9 math.fraction('1.5').toFraction()
                       ~~~~~~~~~~
@josdejong
Copy link
Owner

Thanks for reporting, we should improve the TypeScript definitions. Ideally, we can import and use type definitions from Fraction.js.

Who can help fix the TypeScript definitions of fractions?

@yukulele
Copy link
Contributor Author

I think you might need to update the fraction.js version first, which is out outdated.

@josdejong
Copy link
Owner

Yes, that is addressed via #3283, it is a breaking change planned for v14.

@josdejong
Copy link
Owner

Fixed now in v14.0.1.

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

Successfully merging a pull request may close this issue.

2 participants