Skip to content

Commit 9160933

Browse files
authored
fix(react-intl): update type of the <FormattedNumber> value prop (#4954)
It was hard-coded as `number`. The `formatNumber()` function has been updated to accept [all values that `Intl.NumberFormat.format()` accepts](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/format#number), so this makes the component match the underlying function. The component already works correctly if you pass (for example) a numeric string as the `value` prop. This updates the type checking to match the reality of what the component supports.
1 parent 2fe506d commit 9160933

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/react-intl/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import FormattedPlural from './src/components/plural'
2727
import IntlProvider from './src/components/provider'
2828
import FormattedRelativeTime from './src/components/relative'
2929
import useIntl from './src/components/useIntl'
30+
import {IntlShape} from './src/types'
3031
export {
3132
createIntlCache,
3233
CustomFormatConfig,
@@ -94,7 +95,7 @@ export const FormattedTime: React.FC<
9495
export const FormattedNumber: React.FC<
9596
Omit<NumberFormatOptions, 'localeMatcher'> &
9697
CustomFormatConfig<'number'> & {
97-
value: number
98+
value: Parameters<IntlShape['formatNumber']>[0]
9899
children?(formattedNumber: string): React.ReactElement | null
99100
}
100101
> = createFormattedComponent('formatNumber')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy