#3609·date-fns

Add docs about requried TypeScript settings

Author: alexfung888Created Dec 19, 2023Updated Jul 13, 2026
Labels📃 Docs

I understand that in v3, constants are not exported via the index, but I got the following errors, which do not come from my code:

bash
Error: node_modules/date-fns/intlFormatDistance.d.ts:8:17 - error TS2694: Namespace 'Intl' has no exported member 'BCP47LanguageTag'.

8   locale?: Intl.BCP47LanguageTag | Intl.BCP47LanguageTag[];
                  ~~~~~~~~~~~~~~~~


Error: node_modules/date-fns/intlFormatDistance.d.ts:8:41 - error TS2694: Namespace 'Intl' has no exported member 'BCP47LanguageTag'.

8   locale?: Intl.BCP47LanguageTag | Intl.BCP47LanguageTag[];
                                          ~~~~~~~~~~~~~~~~


Error: node_modules/date-fns/intlFormatDistance.d.ts:10:24 - error TS2694: Namespace 'Intl' has no exported member 'RelativeTimeFormatLocaleMatcher'.

10   localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher;
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Error: node_modules/date-fns/intlFormatDistance.d.ts:12:18 - error TS2694: Namespace 'Intl' has no exported member 'RelativeTimeFormatNumeric'.

12   numeric?: Intl.RelativeTimeFormatNumeric;
                    ~~~~~~~~~~~~~~~~~~~~~~~~~


Error: node_modules/date-fns/intlFormatDistance.d.ts:14:16 - error TS2694: Namespace 'Intl' has no exported member 'RelativeTimeFormatStyle'.

14   style?: Intl.RelativeTimeFormatStyle;
                  ~~~~~~~~~~~~~~~~~~~~~~~

I guess I need to add

typescript
  import { RelativeTimeFormatStyle } from 'date-fns/constants';

somewhere, but where should I add the missing constant imorts?