commit 0591378ff341ce138f2770f23d68c5912fdce77b
parent ba48f9d859551a9d90797402e11149cc2a3d327e
Author: Mark Banner <standard8@mozilla.com>
Date: Mon, 3 Nov 2025 14:08:14 +0000
Bug 1997547 - Add basic Temporal definitions to TypeScript types. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D270828
Diffstat:
2 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/tools/@types/index.d.ts b/tools/@types/index.d.ts
@@ -19,6 +19,7 @@
/// <reference types="./generated/lib.gecko.win32.d.ts" />
/// Order of references matters here, for overriding type signatures.
+/// <reference types="./lib.gecko.esnext.d.ts" />
/// <reference types="./lib.gecko.tweaks.d.ts" />
import type {} from "./lib.gecko.augmentations.d.ts";
diff --git a/tools/@types/lib.gecko.esnext.d.ts b/tools/@types/lib.gecko.esnext.d.ts
@@ -0,0 +1,39 @@
+/**
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+/**
+ * This file is for manual type definitions for things that aren't yet available
+ * in TypeScript, but should be in the next target version (esnext). This
+ * typically occurs when a feature has been implemented in Gecko, but not yet
+ * reached ECMAScript stage 4, or multi-browser support.
+ */
+
+// Additions for Temporal.
+// xref https://github.com/microsoft/TypeScript/pull/62628
+
+/**
+ * Basic simulation of the Temporal interface.
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Temporal
+ */
+declare namespace Temporal {
+ type Instant = any;
+}
+
+declare var Temporal: {
+ Duration: any;
+ Instant: any;
+ Now: any;
+ PlainDate: any;
+ PlainDateTime: any;
+ PlainMonthDay: any;
+ PlainTime: any;
+ PlainYearMonth: any;
+ ZonedDateTime: any;
+};
+
+interface Date {
+ toTemporalInstant(): Temporal.Instant;
+}