Skip to content

Unit.divide(Unit) return type is incorrect when units cancel out #2972

@matt18224

Description

@matt18224

Describe the bug
Version 11.8.1

The return type of Unit.divide(Unit) is Unit, but if the result of the division is a scalar, a number is actually returned.

The divide(Unit, Unit) function has the correct return type: Unit | number.

To Reproduce

const kg = unit('1 kg');
const hundredGrams = unit('100 g');

//typeof divResult === 'number', but return type of function is Unit
const divResult = kg.divide(hundredGrams);
console.log(typeof divResult); //"number"

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions