Skip to content

refactor: move Temporal types to separate lib.temporal.d.ts#32571

Merged
bartlomieju merged 6 commits intodenoland:mainfrom
kajukitli:refactor/temporal-types-to-separate-lib
Mar 8, 2026
Merged

refactor: move Temporal types to separate lib.temporal.d.ts#32571
bartlomieju merged 6 commits intodenoland:mainfrom
kajukitli:refactor/temporal-types-to-separate-lib

Conversation

@kajukitli
Copy link
Copy Markdown
Contributor

Summary

Moves Temporal API type definitions from lib.deno.unstable.d.ts to a new lib.temporal.d.ts file, and references it from lib.deno.window.d.ts and lib.deno.worker.d.ts.

Problem

When users explicitly set compilerOptions.lib in their deno.json, they lose Temporal types unless they also include "deno.unstable". This is confusing because:

  • Temporal is stable in Deno 2.x (no longer behind --unstable-temporal)
  • The runtime always has Temporal available
  • Users shouldn't need to opt into "unstable" for stable features

Solution

Create a separate lib.temporal.d.ts that is auto-included via lib.deno.window.d.ts and lib.deno.worker.d.ts. This ensures Temporal types are always available when using the standard Deno libs.

This approach was suggested in #32468 (comment) and aligns with TypeScript's plan to add esnext.temporal.d.ts in TS 6.0.

Closes #32468

Moves Temporal API type definitions from lib.deno.unstable.d.ts to a
new lib.temporal.d.ts file, and references it from lib.deno.window.d.ts
and lib.deno.worker.d.ts.

This fixes the issue where users who explicitly set compilerOptions.lib
would lose Temporal types unless they also included "deno.unstable".
Since Temporal is now stable in Deno 2.x (no longer behind --unstable-temporal),
users should get Temporal types automatically when using deno.window.

Closes denoland#32468
@bartlomieju
Copy link
Copy Markdown
Member

bartlomieju commented Mar 8, 2026

Waiting on denoland/typescript-go#31

bartlomieju and others added 3 commits March 8, 2026 16:06
The temporal types refactoring shifted `declare var name` in
lib.deno.window.d.ts by one line (599 -> 600 zero-indexed).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bartlomieju bartlomieju merged commit e7bafc9 into denoland:main Mar 8, 2026
220 of 222 checks passed
@maikdevries
Copy link
Copy Markdown

Wouldn't it have made more sense to reference lib.temporal.d.ts from deno.ns due to it being baked into the runtime?

As a case in point, the current suggestion for type checking in combined browser and Deno environments is to use:

{
  "compilerOptions": {
    "lib": ["dom", "deno.ns"]
  }
}

I think it would be even better to reference it from esnext as that's what TS 6.0 will ultimately end up doing anyways.

Aside, if you'd like to enable the Temporal API separately (in above scenario), then the current config.json schema does not even consider temporal or deno.temporal or esnext.temporal a valid option.

@bartlomieju
Copy link
Copy Markdown
Member

@maikdevries feel free to open a PR to change it

@maikdevries
Copy link
Copy Markdown

I'd be happy to do so but first need some clarifications:

  1. The esnext lib already references esnext.temporal, so how come the Temporal API is not available when using deno.ns (which references esnext)?
  2. The definitions in lib.temporal are still marked as experimental, should they be?

@bartlomieju
Copy link
Copy Markdown
Member

  1. I'm not really sure
  2. No, it should not be marked as experimental

@maikdevries
Copy link
Copy Markdown

To answer the first: #32656 seems to have introduced esnext.temporal definitions and removed any references to lib.temporal in the process.

So if I understand correctly, there's nothing for me to do other than wait for the next release and it will sort itself out automatically (both deno.ns enabling Temporal API and the schema for deno.json no longer needing deno.temporal). This still leaves the unused lib.temporal definition file dangling in the repository though.

@bartlomieju
Copy link
Copy Markdown
Member

Good catch - you can try this already with deno canary. But yeah lib.temporal should be removed.

bartlomieju added a commit to bartlomieju/deno that referenced this pull request Mar 24, 2026
Add "esnext.temporal" to the lib_names list in
get_types_declaration_file_text() so that `deno types` emits the
Temporal namespace declarations from TypeScript's
lib.esnext.temporal.d.ts.

This was accidentally removed in denoland#32656 (typescript-go update) which
dropped the "deno.temporal" entry added by denoland#32571. Since deno types
does flat concatenation (doesn't follow /// <reference> chains), the
Temporal types were silently lost from the output.

Closes denoland#32950

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bartlomieju added a commit that referenced this pull request Mar 25, 2026
## Summary

Add `"esnext.temporal"` to the `lib_names` list in
`get_types_declaration_file_text()` so that `deno types` emits the
Temporal namespace declarations from TypeScript's
`lib.esnext.temporal.d.ts`.

This was accidentally removed in #32656 (typescript-go update) which
dropped the `"deno.temporal"` entry added by #32571. Since `deno types`
does flat concatenation (doesn't follow `/// <reference>` chains), the
Temporal types were silently lost from the output, breaking docs
generation at docs.deno.com.

Closes #32950

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deno lsp still expects "deno.unstable" on compilerOptions.lib for Temporal API

3 participants