fix: Export DayOfWeek type from @internationalized/date#10234
Open
patrickwehbe wants to merge 1 commit into
Open
fix: Export DayOfWeek type from @internationalized/date#10234patrickwehbe wants to merge 1 commit into
patrickwehbe wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9971
Problem
DayOfWeek('sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat') appears in the public signatures of the exportedgetDayOfWeek,startOfWeek,endOfWeek, andgetWeeksInMonthfunctions as the optionalfirstDayOfWeekparameter, but the type itself is not exported:Consumers who accept
firstDayOfWeekas a prop and forward it to these functions have no canonical type to use; they must duplicate the string union.Root cause
DayOfWeekwas declared withoutexportinsrc/queries.tsand never re-exported fromsrc/index.ts. Previously TypeScript would let tooling import it from the.d.tsanyway, but after the package moved to theexportsfield inpackage.jsonthe 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
exportto theDayOfWeektype declaration inqueries.ts.index.tsnext to the other public type exports.Purely additive — no existing export of
DayOfWeekexists elsewhere in the repo, so nothing is shadowed or duplicated.Verification
git grepconfirmsDayOfWeekhad no other export and no downstream package references it (no conflict).tscthatexport type {DayOfWeek} from './queries'resolves to a real exported member (noTS2305 "no exported member"error).