Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#52826 fix(number-to-words): UMD support an…
Browse files Browse the repository at this point in the history
…d input type fix by @peterblazejewicz

- this library suppots string numeric values as inputs. It's event
  documented in the source code:
https://github.com/marlun78/number-to-words/blob/master/numberToWords.js#L146
- add proper UMD support to use in the browsers:
https://github.com/marlun78/number-to-words/blob/master/numberToWords.js#L252-L259
- tests amended

Thanks!
  • Loading branch information
peterblazejewicz authored May 8, 2021
1 parent 4b34964 commit 4eeb93a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
10 changes: 7 additions & 3 deletions types/number-to-words/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
// Definitions by: Frederick Fogerty <https://github.com/frederickfogerty>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

export as namespace numberToWords;

/**
* Converts an integer into a string with an ordinal postfix. If number is decimal, the decimals will be removed.
*/
export function toOrdinal(number: number): string;
export function toOrdinal(number: string | number): string;

/**
* Converts an integer into words. If number is decimal, the decimals will be removed.
*/
export function toWords(number: number): string;
export function toWords(number: string | number): string;

/**
* Converts a number into ordinal words. If number is decimal, the decimals will be removed.
*/
export function toWordsOrdinal(number: number): string;
export function toWordsOrdinal(number: string | number): string;
11 changes: 7 additions & 4 deletions types/number-to-words/number-to-words-tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as converter from 'number-to-words';
import numberToWords = require("number-to-words");

converter.toOrdinal(21);
numberToWords.toOrdinal(21); // $ExpectType string
numberToWords.toOrdinal("21"); // $ExpectType string

converter.toWords(13);
numberToWords.toWords(13); // $ExpectType string
numberToWords.toWords("13"); // $ExpectType string

converter.toWordsOrdinal(21);
numberToWords.toWordsOrdinal(21); // $ExpectType string
numberToWords.toWordsOrdinal("21"); // $ExpectType string

0 comments on commit 4eeb93a

Please sign in to comment.