Skip to content

fix: export DateUtils from the package entry point - #12566

Merged
alumni merged 3 commits into
typeorm:masterfrom
MahinAnowar:fix/export-dateutils
Aug 26, 2026
Merged

alumni merged 3 commits into
typeorm:masterfrom
MahinAnowar:fix/export-dateutils

Conversation

@MahinAnowar

Copy link
Copy Markdown
Contributor

What

Closes #3948.

DateUtils (src/util/DateUtils.ts) is used to format/normalize dates for raw SQL queries, but unlike its sibling utilities InstanceChecker and TreeRepositoryUtils it 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/types point 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:

export { InstanceChecker } from "./util/InstanceChecker"
export { TreeRepositoryUtils } from "./util/TreeRepositoryUtils"
export { DateUtils } from "./util/DateUtils"

import { DateUtils } from "typeorm" now works.

Tests

Added test/unit/util/date-utils.test.ts (pure unit test, no DB) asserting that:

  • DateUtils is exported from the package entry point and is the same reference as the direct module export;
  • its static helpers are reachable through the public 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.

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
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. No docs for DateUtils export 📘 Rule violation ⚙ Maintainability
Description
This PR adds DateUtils to the public typeorm entry point, which is a user-facing API change, but
no documentation/samples were updated to reflect the new supported import path. Users may not
discover the new public import and may continue relying on deep imports.
Code

src/index.ts[185]

+export { DateUtils } from "./util/DateUtils"
Evidence
PR Compliance ID 2 requires documentation updates for user-facing API/usage changes. The PR adds a
new public export DateUtils from the package entry point, and the accompanying unit test
explicitly frames this as a consumer-facing entry-point import regression.

Rule 2: Docs updated for user-facing changes
src/index.ts[185-185]
test/unit/util/date-utils.test.ts[3-7]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A new public export (`DateUtils`) was added to the package entry point, but the docs do not mention this new supported import path.
## Issue Context
`DateUtils` is intended for consumers (e.g., formatting/normalizing dates for raw SQL queries) and this PR makes `import { DateUtils } from "typeorm"` possible. Per the checklist, user-facing API/usage changes should be reflected in documentation or samples.
## Fix Focus Areas
- src/index.ts[185-185]
- docs/docs/data-source/4-data-source-api.md[138-193]
- docs/docs/working-with-entity-manager/5-entity-manager-api.md[27-76]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Grey Divider

Tip of the day
💡 Did you know, you can start a comment with 'qodo' or '@qodo' to chat about any finding

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@MahinAnowar

Copy link
Copy Markdown
Contributor Author

On the docs flag from the bot — I looked at whether the two sibling util exports are documented, and neither is: InstanceChecker and TreeRepositoryUtils both get zero hits anywhere under docs/. So this PR is consistent with how the existing util re-exports are treated, and adding a docs page just for DateUtils would put it ahead of its siblings rather than in line with them.

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.

@pkg-pr-new

pkg-pr-new Bot commented Aug 26, 2026

Copy link
Copy Markdown
  • typeorm-sql-js-example

    npm i https://pkg.pr.new/typeorm@12566
    

commit: 1a5242e

@alumni

alumni commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

So this PR is consistent with how the existing util re-exports are treated

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 DateUtils, since we'd like to review the way dates are handled in the future.

@alumni alumni changed the title feat: export DateUtils from the package entry point fix: export DateUtils from the package entry point Aug 26, 2026
@github-actions github-actions Bot added the linked-issue PR references an issue label Aug 26, 2026
@alumni
alumni merged commit 9fed5b4 into typeorm:master Aug 26, 2026
49 checks passed
@github-actions github-actions Bot added this to the 2.0.next milestone Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linked-issue PR references an issue

Development

Successfully merging this pull request may close these issues.

Export DateUtils in typeorm module

2 participants