Skip to content

Commit

Permalink
refactor: change to not using declare class
Browse files Browse the repository at this point in the history
  • Loading branch information
orelbn committed Jul 8, 2024
1 parent 88006ea commit 69d3d17
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ export interface MathJsInstance extends MathJsFactory {
RelationalNode: RelationalNodeCtor
SymbolNode: SymbolNodeCtor

Unit: UnitCtor
Matrix: MatrixCtor

/**
Expand Down Expand Up @@ -4011,11 +4012,7 @@ export interface UnitPrefix {
scientific: boolean
}

export declare class Unit {
constructor(
value: number | BigNumber | Fraction | Complex | boolean,
name: string
)
export interface Unit {
valueOf(): string
clone(): Unit
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -4042,19 +4039,16 @@ export declare class Unit {
value: number
fixPrefix: boolean
skipAutomaticSimplification: true
/**
* Parse a string into a unit. The value of the unit is parsed as number, BigNumber, or Fraction depending on the math.js config setting number.
*
* Throws an exception if the provided string does not contain a valid unit or cannot be parsed.
*/
static parse: (str: string) => Unit
/** Test if the given expression is a unit.
*
* The unit can have a prefix but cannot have a value.
*/
static isValuelessUnit: (name: string) => boolean
/** Instantiate a Unit from a JSON object */
static fromJSON: (json: object) => Unit
}

export interface UnitCtor {
new (
value: number | BigNumber | Fraction | Complex | boolean,
name: string
): Unit
parse(str: string): Unit
isValuelessUnit(name: string): boolean
fromJSON(json: object): Unit
}

export interface CreateUnitOptions {
Expand Down Expand Up @@ -6863,6 +6857,7 @@ export const {
RelationalNode,
SymbolNode,
Matrix,
Unit,

uninitialized,
version,
Expand Down

0 comments on commit 69d3d17

Please sign in to comment.