Repository navigation
fix: export DateUtils from the package entry point - #12566
Conversation
DateUtils is used to format/normalize dates for raw queries, but unlike its sibling utilities (InstanceChecker, TreeRepositoryUtils) it was not re-exported from the package entry point. Now that TypeORM ships pre-bundled, deep-importing typeorm/util/DateUtils is unreliable, so expose it from the public entry instead. Closes typeorm#3948
Code Review by Qodo
1. No docs for DateUtils export
|
|
On the docs flag from the bot — I looked at whether the two sibling util exports are documented, and neither is: Happy to write something if you'd rather have all three documented together, but that felt like a separate call for a maintainer to make, not something to fold into a one-line export. |
commit: |
That's fine - I would not document such things. These are rather internal APIs - even though we export them for ease-of-use, we should encourage people to use them actively, especially |
What
Closes #3948.
DateUtils(src/util/DateUtils.ts) is used to format/normalize dates for raw SQL queries, but unlike its sibling utilitiesInstanceCheckerandTreeRepositoryUtilsit was never re-exported from the package entry point (src/index.ts).Consumers therefore had to deep-import
typeorm/util/DateUtils. As the issue reporter notes, that path is no longer reliable now that TypeORM ships pre-bundled (main/typespoint at./index.js/./index.d.ts), so internal paths aren't guaranteed stable. A maintainer asked for a PR on the issue.Fix
Add one line to
src/index.ts, mirroring the existing util re-exports:import { DateUtils } from "typeorm"now works.Tests
Added
test/unit/util/date-utils.test.ts(pure unit test, no DB) asserting that:DateUtilsis exported from the package entry point and is the same reference as the direct module export;mixedDateToDateString).Verified the test fails to compile on the previous code (
TS2305: Module '"../../../src"' has no exported member 'DateUtils') and passes after the fix.pnpm run compile, Prettier, and ESLint are all clean.