Skip to content

fix: Export DayOfWeek type from @internationalized/date#10234

Open
patrickwehbe wants to merge 1 commit into
adobe:mainfrom
patrickwehbe:export-dayofweek-type
Open

fix: Export DayOfWeek type from @internationalized/date#10234
patrickwehbe wants to merge 1 commit into
adobe:mainfrom
patrickwehbe:export-dayofweek-type

Conversation

@patrickwehbe

Copy link
Copy Markdown

Closes #9971

Problem

DayOfWeek ('sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat') appears in the public signatures of the exported getDayOfWeek, startOfWeek, endOfWeek, and getWeeksInMonth functions as the optional firstDayOfWeek parameter, but the type itself is not exported:

import { type DayOfWeek } from '@internationalized/date';
// TS error: '"@internationalized/date"' has no exported member named 'DayOfWeek'.

Consumers who accept firstDayOfWeek as a prop and forward it to these functions have no canonical type to use; they must duplicate the string union.

Root cause

DayOfWeek was declared without export in src/queries.ts and never re-exported from src/index.ts. Previously TypeScript would let tooling import it from the .d.ts anyway, but after the package moved to the exports field in package.json the declaration file it lived in is no longer reachable, so it became unimportable.

As discussed in the issue, a maintainer was open to exporting it formally ("we can consider exporting it formally").

Fix

  • Add export to the DayOfWeek type declaration in queries.ts.
  • Re-export it from index.ts next to the other public type exports.

Purely additive — no existing export of DayOfWeek exists elsewhere in the repo, so nothing is shadowed or duplicated.

Verification

  • git grep confirms DayOfWeek had no other export and no downstream package references it (no conflict).
  • Type-checked with tsc that export type {DayOfWeek} from './queries' resolves to a real exported member (no TS2305 "no exported member" error).

The `DayOfWeek` union type (`'sun' | 'mon' | ... | 'sat'`) is used in the
public signatures of the exported `getDayOfWeek`, `startOfWeek`,
`endOfWeek`, and `getWeeksInMonth` functions (as the optional
`firstDayOfWeek` parameter), but the type itself was declared without
`export` in `queries.ts` and was not re-exported from `index.ts`.

After the package moved to the `exports` field in package.json, the
declaration file it lived in was no longer reachable, so consumers could
no longer import it to type their own `firstDayOfWeek` props.

Export the type formally so it can be imported alongside the functions
that use it.

Closes adobe#9971
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.

DayOfWeek type no longer importable from @internationalized/date after 3.12.1

1 participant