mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[convert-units] Make convert function value param optional. (#44225)
The `convert` function can be used with no `value` argument, but previously the type definition for this module required it. - Made `value` param to `convert` function optional. - Added tests for that use case.
This commit is contained in:
parent
dba40a97b6
commit
29ece6dcb3
@ -4,3 +4,16 @@ const convertedMass = convert(25).from('mcg').to('t');
|
||||
const convertedMassBack = convert(convertedMass).from('t').to('mcg');
|
||||
|
||||
const unit = convert(66).getUnit<'mcg'>('mcg');
|
||||
|
||||
// Using `convert` without a value.
|
||||
const measures = convert().measures();
|
||||
const allUnits = convert().possibilities();
|
||||
const massUnits = convert().possibilities('mass');
|
||||
const distanceUnits = convert().from('m').possibilities();
|
||||
const kgDescription = convert().describe('kg');
|
||||
|
||||
const kgAbbr: string = kgDescription.abbr;
|
||||
const kgMeasure: string = kgDescription.measure;
|
||||
const kgSystem: string = kgDescription.system;
|
||||
const kgSingular: string = kgDescription.singular;
|
||||
const kgPlural: string = kgDescription.plural;
|
||||
|
||||
3
types/convert-units/index.d.ts
vendored
3
types/convert-units/index.d.ts
vendored
@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/ben-ng/convert-units#readme
|
||||
// Definitions by: vladkampov <https://github.com/vladkampov>
|
||||
// ben-ng <https://github.com/ben-ng>
|
||||
// Toby Bell <https://github.com/tobybell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
@ -129,6 +130,6 @@ declare class Convert {
|
||||
measures(): measure[];
|
||||
}
|
||||
|
||||
declare function convert(value: number): Convert;
|
||||
declare function convert(value?: number): Convert;
|
||||
|
||||
export = convert;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user