Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

groups missing in interface Options for typescript #450

Open
yuklai opened this issue Jul 6, 2023 · 1 comment
Open

groups missing in interface Options for typescript #450

yuklai opened this issue Jul 6, 2023 · 1 comment

Comments

@yuklai
Copy link

yuklai commented Jul 6, 2023

Hi all, when Format function's option (Options interface) parameter should have a groups attribute, right?
It's missing in the typescript definition for me but when I step through the code, groups is valid.

I'm using the latest 2.0.4 version. Did I miss anything? Thanks!

declare module 'currency.js' {
  namespace currency {
    type Any = number | string | currency;
    type Format = (currency?: currency, opts?: Options) => string;
    interface Constructor {
      (value: currency.Any, opts?: currency.Options): currency,
      new(value: currency.Any, opts?: currency.Options): currency
    }
    interface Options {
      symbol?: string,
      separator?: string,
      decimal?: string,
      errorOnInvalid?: boolean,
      precision?: number,
      increment?: number,
      useVedic?: boolean,
      pattern?: string,
      negativePattern?: string,
      format?: currency.Format,
      fromCents?: boolean
    }
  }

  interface currency {
    add(number: currency.Any): currency;
    subtract(number: currency.Any): currency;
    multiply(number: currency.Any): currency;
    divide(number: currency.Any): currency;
    distribute(count: number): Array<currency>;
    dollars(): number;
    cents(): number;
    format(opts?: currency.Options | currency.Format): string;
    toString(): string;
    toJSON(): number;
    readonly intValue: number;
    readonly value: number;
  }

  const currency: currency.Constructor;

  export = currency;
}
@Ryiski
Copy link

Ryiski commented Oct 29, 2023

@yuklai The groups attribute is for internal use, it simply stores a regex, based on the numbering system you picked, all you have to do is select the numbering system using useVedic attribute

Even if you managed to pass a groups attribute, it will always be overwritten by the else clause, so I'd say don't worry much about it 😁

  if(settings.useVedic) {
    settings.groups = vedicRegex;
  } else {
    settings.groups = groupRegex;
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants