Skip to content

part option for n fails with an error #1165

@mv-go

Description

@mv-go

Reporting a bug?

Using part option for number formatter throws an error. JSfiddle below.

Example usage:

const i18n = createI18n({
  locale: 'en',
  legacy: false,
  numberFormats: {
    en: {
      currency: {
        style: 'currency',
        currencyDisplay: 'narrowSymbol',
      },
    }
})

const { n } = useI18n()

const parts = n(100, { key: 'currency', part: true, currency: 'USD' })

Expected behavior

  • not to throw error
  • return an array of parts, so have the same return signature as Intl.NumberFormatter.prototype.formatToParts

Reproduction

https://jsfiddle.net/qagtkzxj/39/

System Info

System:
    OS: macOS 12.5.1
    CPU: (8) arm64 Apple M1
    Memory: 80.39 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.18 - /opt/homebrew/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Browsers:
    Chrome: 104.0.5112.101
    Firefox: 94.0.2
    Firefox Developer Edition: 105.0
    Safari: 15.6.1
  npmPackages:
    vue: ^3.2.36 => 3.2.37 
    vue-chartjs: ^4.1.1 => 4.1.1 
    vue-i18n: ^9.2.2 => 9.2.2 
    vue-router: ^4.1.5 => 4.1.5

Screenshot

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions