File tree 1 file changed +8
-5
lines changed
packages/use-intl/src/react
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 7
7
type DateTimeFormatOptions ,
8
8
type IntlError ,
9
9
IntlErrorCode ,
10
- type NumberFormatOptions
10
+ type NumberFormatOptions ,
11
+ type RelativeTimeFormatOptions
11
12
} from '../core.js' ;
12
13
import IntlProvider from './IntlProvider.js' ;
13
14
import useFormatter from './useFormatter.js' ;
@@ -432,13 +433,15 @@ describe('number', () => {
432
433
describe ( 'relativeTime' , ( ) => {
433
434
function renderRelativeTime (
434
435
date : Date | number ,
435
- nowOrOptions : Parameters <
436
- ReturnType < typeof useFormatter > [ 'relativeTime' ]
437
- > [ '1' ]
436
+ nowOrOptions : Date | number | RelativeTimeFormatOptions
438
437
) {
439
438
function Component ( ) {
440
439
const format = useFormatter ( ) ;
441
- return < > { format . relativeTime ( date , nowOrOptions ) } </ > ;
440
+ if ( nowOrOptions instanceof Date || typeof nowOrOptions === 'number' ) {
441
+ return format . relativeTime ( date , nowOrOptions ) ;
442
+ } else {
443
+ return format . relativeTime ( date , nowOrOptions ) ;
444
+ }
442
445
}
443
446
444
447
render (
You can’t perform that action at this time.
0 commit comments