Skip to content

Export Formatter, Unit and Suffix types#231

Merged
nmn merged 1 commit into
nmn:masterfrom
amorey:230-add-missing-typedefs
Jul 27, 2025
Merged

Export Formatter, Unit and Suffix types#231
nmn merged 1 commit into
nmn:masterfrom
amorey:230-add-missing-typedefs

Conversation

@amorey
Copy link
Copy Markdown
Contributor

@amorey amorey commented Jul 26, 2025

Fixes #230

This PR exports Formatter, Unit and Suffix types which were present in v7. Now you can do this again:

import type { Formatter, Suffix, Unit } from 'react-timeago';

const myCustomFormatter: Formatter = (
  value: number,
  unit: Unit,
  suffix: Suffix,
  epochMilliseconds: number,
  nextFormatter: Formatter,
  now: () => number,
) => {
  if (suffix === 'from now' || unit === 'second') return 'just now';
  if (nextFormatter) return nextFormatter(value, unit, suffix, epochMilliseconds, nextFormatter, now);
  return '';
};

Signed-off-by: Andres Morey <andresmarcel@gmail.com>
@nmn nmn merged commit 46814ad into nmn:master Jul 27, 2025
3 checks passed
Philipp91 added a commit to Philipp91/react-timeago that referenced this pull request May 9, 2026
Fixes nmn#234.

nmn#231 had turned the `import type` line into an `export type` line to re-export the types, but missed that [re-exported types "do not become available inside the current module"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export#re-exporting_aggregating), yet the `Formatter` type is actually used within the same file.
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

Successfully merging this pull request may close these issues.

TypeScript definitions missing in v8

2 participants