Skip to content

TypeScript: ZonedDateTime.from() doesn't require timeZone property, but runtime throws error #352

@MOhhh-ok

Description

@MOhhh-ok

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions