Current Behavior
When calling Temporal.ZonedDateTime.from() with an object that's missing the required timeZone property, TypeScript does not report a type error. However, at runtime, the code throws:
Uncaught TypeError: required property 'timeZone' missing or undefined
Example Code
import { Temporal } from "@js-temporal/polyfill";
// TypeScript does NOT error on this, but it should
const zdt = Temporal.ZonedDateTime.from({
year: 2026,
month: 1,
day: 1
// missing timeZone!
});
Expected Behavior
TypeScript should report a type error indicating that timeZone is required.
Root Cause
In index.d.ts, the ZonedDateTimeLike type defines timeZone as optional:
export type ZonedDateTimeLike = {
// ... other properties
timeZone?: TimeZoneLike; // ← should NOT be optional
// ... other properties
};
Suggested Fix
The timeZone property should be required in ZonedDateTimeLike:
export type ZonedDateTimeLike = {
// ... other properties
timeZone: TimeZoneLike; // ← remove the `?`
// ... other properties
};
Environment
@js-temporal/polyfill version: 0.5.1
- TypeScript version: 5.9.3