fix: make TemporalValue self-contained#49
Merged
wellwelwel merged 2 commits intoJul 12, 2026
Conversation
…pace The emitted types.d.ts referenced `Temporal.*` bare, so consumers whose tsconfig lacks the `ESNext.Temporal` lib (all of TypeScript < 7) failed with `TS2503: Cannot find namespace 'Temporal'` — e.g. mysql2's typecheck after bumping to sql-escaper 1.5.0 (sidorares/node-mysql2#4216). Type TemporalValue structurally, branded on Symbol.toStringTag to match the runtime isTemporal check. Real Temporal values still assign; no global namespace, no ESNext.Temporal lib required downstream. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #49 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 561 561
Branches 170 170
=========================================
Hits 561 561 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wellwelwel
reviewed
Jul 12, 2026
TemporalValue self-contained
pdeveltere
added a commit
to pdeveltere/node-mysql2
that referenced
this pull request
Jul 12, 2026
sql-escaper v1.5.x adds Temporal API support (Temporal.Instant, PlainDate, PlainTime, PlainDateTime, ZonedDateTime) when escaping values. Bumping the direct dependency ensures existing installations pick up the support on `npm update` rather than only on fresh installs. 1.5.1 is required: 1.5.0's emitted types referenced the global Temporal namespace, breaking `tsc` for consumers without the ESNext.Temporal lib (fixed in mysqljs/sql-escaper#49). Refs sidorares#4216 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
wellwelwel
pushed a commit
to sidorares/node-mysql2
that referenced
this pull request
Jul 13, 2026
sql-escaper v1.5.x adds Temporal API support (Temporal.Instant, PlainDate, PlainTime, PlainDateTime, ZonedDateTime) when escaping values. Bumping the direct dependency ensures existing installations pick up the support on `npm update` rather than only on fresh installs. 1.5.1 is required: 1.5.0's emitted types referenced the global Temporal namespace, breaking `tsc` for consumers without the ESNext.Temporal lib (fixed in mysqljs/sql-escaper#49). Refs #4216 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
The published
lib/types.d.tsreferences the globalTemporal.*namespace:That only resolves if the consumer's tsconfig includes the
ESNext.Temporallib, which exists only in TypeScript 7. Every consumer on TypeScript < 7 (the vast majority today) gets:This surfaced when mysql2 bumped its direct dependency to
sql-escaper@1.5.0— itstscbuild now fails (sidorares/node-mysql2#4216, PR sidorares/node-mysql2#4392).Fix
Type
TemporalValuestructurally, branded onSymbol.toStringTag— the same signal the runtimeisTemporalcheck already uses:Temporalnamespace → resolves on any TypeScript version, no lib or polyfill types needed downstream.Instant,PlainDate,PlainTime,Duration, …) still assigns — verified against@js-temporal/polyfill.temporalToString's guard switched from'epochMilliseconds' in valuetotypeof value.epochMilliseconds === 'number'(equivalent at runtime, narrows the optional cleanly).ESNext.Temporalfrom the buildlibsince nothing references the global anymore.Existing tests (incl.
temporal.test.ts) pass; build and lint are green.