diff --git a/types/index.d.ts b/types/index.d.ts index 3784187fec..9b2a9be0ee 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -508,6 +508,7 @@ export interface MathJsInstance extends MathJsFactory { RelationalNode: RelationalNodeCtor SymbolNode: SymbolNodeCtor + Unit: UnitCtor Matrix: MatrixCtor /** @@ -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 @@ -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 { @@ -6863,6 +6857,7 @@ export const { RelationalNode, SymbolNode, Matrix, + Unit, uninitialized, version,