40 Commits

Author SHA1 Message Date
Chris Chudzicki
13a3d4c198
Linting: StandardJS for src/, test/; Prettier for types/ (#2544)
* setup linting with eslint-config-standard, prettier

* [autofix] npm run lint -- --fix with new setup

* [manual] fix types/ directory errors

* [manual] fix linting errors in test/ directory

* [manual] fix single linting error in src/

* revert ts-expect-error comment change

* error on .only in mocha tests

* fix test description typo

* move some short objects to single line

* add and gitignore eslintcache

* individually suppress ts any

* set --max-warnings to 0

* extract matrices to constants

* update ts-expect-error comments
2022-04-29 12:04:01 +02:00
Glen Whitney
82074e85e0
fix: Type declarations for rounding functions (#2539)
This is a sequel to #2531. Uniformizes the signatures of ceil, fix, floor,
  and round, and updates the TypeScript declarations to match. Adds the
  optional "number of places" argument to the chain versions of ceil, fix,
  and floor. Adds TypeScript tests for all rounding functions.

  Also corrects the TypeScript declaration for `bignumber()` and introduces
  a couple more common abbreviations for TypeScript types.

  Fixes the number-only implementations of floor, ceil, fix, and nthRoot
  to match the full implementation behavior on numbers, and tests this for
  floor.

  Includes some minor documentation updates and additional unit tests for
  the rounding functions.

  Reverts inclusion in AUTHORS of incorrect email for one contributor,
  that occurred in #2531.

  Resolves #2526.
  Resolves #2529.
2022-04-25 12:07:02 +02:00
simlaticak
45514a832e
Updated ceil types (#2531)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-04-19 14:31:49 +02:00
yifanwww
b3f564f266
feat: Implement lgamma function -- log(gamma(z))) -- for number and Complex (#2417)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
2022-04-11 20:00:16 -07:00
Chris Chudzicki
99839a8da3
Add TypeScript definitions for src/utils/is.js (#2432)
This is a first step toward full publication of these functions,
that were already being exported by mathjs but had not yet
had the associated actions (documentation/available in 
parser/typed, etc.) Also, makes most of them into TypeScript
type guards, and adds Matrix as a constructor type. Resolved #2431.

Co-authored-by: Glen Whitney <glen@studioinfinity.org>
2022-03-17 16:17:32 -07:00
NattapongSiri
b8d2e81ee7
fix(TypeScript): Make dim argument optional for std and variance (#2474)
Also adds TypeScript test cases for these functions.

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-03-16 14:01:43 -07:00
Sinan
408094a7a4
Added unit(unit: Unit) TS overload (#2479)
* Added unit(unit: Unit) TS overload
2022-03-15 17:40:54 +01:00
Sam Estep
bb9eb4e0ec
Add checks for type declarations (#2448)
* Add overloads for Matrix add and subtract

* Add check for types/index.ts

* Fix type errors in types/index.ts

* Fix a couple execution errors

* Run test:types as part of test:all

* Fix remaining errors

* Replace types/index.ts comments with asserts

* Add tests for narrowed type inference

* Add dual-purpose comment at top of types/index.ts

* Update AUTHORS

* Use Glen's alternate test:types suggestion
2022-03-08 15:59:35 +01:00
Jos de Jong
c957d41053
Implement cumsum function for computing cumulative sums (#1870)
Resolves #1633

Co-authored-by: Hjortur Jonasson <hjorturjonasson@gmail.com>
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
2022-03-05 23:06:51 -08:00
NattapongSiri
145c540627
Fix std and variance type definition for #2429 (#2455)
* Fix std and variance type definition

* Fix JSDoc and add overload for var/std of chain

* Fix array type and remove duplicate norm type

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-03-04 11:03:07 +01:00
Josh Hansen
89bcd4776f
Reflect simplifyCore relocation in Typescript (#2456) 2022-03-02 08:32:05 +01:00
Glen Whitney
dd1d08a175
docs(subset): Improve documentation of indices (#2446)
Incorporates (and supersedes) #2326 and the discussion therein.
  Resolves #2325.

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-03-01 14:36:42 +01:00
yifanwww
15c4254bc9
feat: Make gamma generic (#2416)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-02-28 09:15:25 +01:00
Josh Hansen
1b34c580f6
fix(types): Unit Typescript type update (#2450)
Add missing BigNumber parameter type to `math.unit` and add types for Unit.simplify and Unit.units
  Resolves #2353.
2022-02-27 23:45:47 -08:00
Divya Yeruva
43d4551e7c
add rotate definition to index.d.ts (#2419)
Co-authored-by: Yeruva <Divya.Yeruva@pepsico.com>
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-02-16 12:42:00 +01:00
Jos de Jong
ce679898f7 Fix #2401: TypeScript definition of ConfigOptions missing option predictable 2022-01-30 20:28:52 +01:00
Thomas Lupin
494ae2a2f0
Fix toHTML type (#2343)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2021-11-03 16:08:48 +01:00
Jos de Jong
f3bea2125e Apply Typescript improvements of commit fc5c202e again 2021-11-03 16:06:15 +01:00
Jos de Jong
fd75ee664f Revert TypeScript improvements of v9.5.1 because they contain breaking changes (see #2339, #2332) 2021-11-03 15:49:44 +01:00
Diana Toader
2ce542c131
fix typescript bug for apply function #2313 (#2330)
Co-authored-by: Diana Toader <dianatoader@Dianas-MacBook-Pro.local>
2021-10-13 12:25:06 +02:00
Jos de Jong
fc5c202e53 Merge branch 'typescript_improvements' of https://github.com/LearnSomethingTeam/mathjs into LearnSomethingTeam-typescript_improvements 2021-10-02 09:41:33 +02:00
Jos de Jong
ed0fe9678e Fix #2319: make the API of Parser.evaluate consistent with math.evaluate: support a list with expressions as input 2021-09-20 21:42:36 +02:00
Josh Hansen
8317eb5545 Re-fix the isConditionalNode typo that was corrected in 9.4.5 2021-09-17 01:54:32 -07:00
Josh Hansen
d01d9ea101 Redefine MathNode as a union type of interfaces implementing MathNodeCommon 2021-09-17 01:48:11 -07:00
Josh Hansen
402fa0e362 Array<SimplifyRule> -> SimplifyRule[] 2021-09-17 01:46:33 -07:00
Josh Hansen
8a80ed83a4 Add ConstantNode as an alias for MathNode and return it 2021-09-17 01:46:27 -07:00
Josh Hansen
0a9881e3cf Make AssignmentNode extend MathNode 2021-09-17 01:46:22 -07:00
Josh Hansen
386f21efbd Various improvements to the Typescript typings
Allows instantiation of classes (e.g. new ConstantNode(5))

Corrects the default invocation of `rationalize` (the signatures were in
the wrong order---MathNode is now the default return type)

Makes `create` return a `MathJsStatic` rather than
`Partial<MathJsStatic>` which is painful to use and largely unnecessary
because most fields on MathJsStatic are already optional.

Adds convenient aliases for `subtract`

Adds `implicit?: boolean` to MathNode

Make the unit on Unit.toNumber and Unit.toNumeric optional like it is in practice

Represent math.simplify.rules and math.simplify.simplifyCore
2021-09-17 01:46:16 -07:00
Wim Devos
d3c63677d0
Update SetCartesian documentation (#2310)
* Update SetCartesian documentation

* Remove trailing spaces

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2021-09-15 22:08:43 +02:00
Michal Grňo
37cc651df2
Fix typo in isConditionalNode in types/index.d.ts (#2307)
`isConditionalnode` → `isConditionalNode`

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2021-09-15 09:52:38 +02:00
Michal Grňo
64909e7fc2
add isRelationalNode to MathNode in types/index.d.ts (#2308)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2021-09-15 09:42:29 +02:00
Kiran Chand
34e461aec4
Adding type definition for hasNumericValue (#2281)
* adding hasNumericValue to types

* adding hasNumericValue to types

Co-authored-by: write2kcl <write2kcltech@alamy.com>
2021-09-15 09:29:05 +02:00
Kiran Chand
0850ac2ca6
Fixing incorrect typing error for floor function. (#2246)
* fixing incorrect typing error for floor function

* removing prettier auto format

Co-authored-by: write2kcl <write2kcltech@alamy.com>
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2021-06-23 10:45:16 +02:00
Manuel Serra
6e2abc90ec
Fix outdated types (#2252)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2021-06-23 10:43:50 +02:00
Opportunity
7fea45d4a3
Add types for custom parsing functions (#2228)
* Add types for custom parsing functions

See https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52648

* Update index.ts

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2021-06-05 11:42:55 +02:00
andrebianchessi
abdd258ac2
Adds types for eigs function (#2216)
* Adds types for eigs. fixes #2100

* adds space

* BigNumber[] fix
2021-05-19 16:25:13 +02:00
Jos de Jong
477906d65a Fix #2123: add type definitions for functions row and column 2021-05-09 15:31:03 +02:00
Jos de Jong
40f515f9a1 Fix #2185: Fix TypeScript definition of unit division, which can also return a number 2021-05-09 15:29:12 +02:00
Jos de Jong
14c730ba53 Fix #2019: Remove null from the TypeScript definitions 2021-05-09 15:26:52 +02:00
Meow
2b402f7cc3
Add type declaration of DefinitelyTyped (#2192)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2021-05-09 15:20:27 +02:00