From e522f4b65a3439030506733b104498f21422ede0 Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Wed, 11 Sep 2024 06:36:43 +0900 Subject: BREAKING(temporal/unstable): Remove obsoleted Temporal APIs part 2 (#25505) Mainly I removed `Temporal.Calendar` and `Temporal.TimeZone` and replaced them to APIs that handle calendar and timezone as strings. https://github.com/tc39/proposal-temporal/pull/2925 Related #24836 --- cli/tsc/dts/lib.deno.unstable.d.ts | 508 +-------------------- ext/console/01_console.js | 8 - runtime/js/99_main.js | 208 +++++++-- tests/integration/lsp_tests.rs | 180 -------- tests/integration/run_tests.rs | 14 - .../specs/run/unstable_temporal_api/__test__.jsonc | 19 + tests/specs/run/unstable_temporal_api/deno.json | 3 + tests/specs/run/unstable_temporal_api/main.out | 10 + tests/specs/run/unstable_temporal_api/main.ts | 59 +++ .../run/unstable_temporal_api/missing_flag.js | 1 + .../run/unstable_temporal_api/missing_flag.out | 7 + .../run/unstable_temporal_api_list/__test__.jsonc | 5 + .../specs/run/unstable_temporal_api_list/main.out | 148 ++++++ tests/specs/run/unstable_temporal_api_list/main.ts | 37 ++ .../run/unstable_temporal_api_patch/__test__.jsonc | 5 + .../specs/run/unstable_temporal_api_patch/main.out | 7 + .../specs/run/unstable_temporal_api_patch/main.ts | 11 + tests/testdata/run/unstable_temporal_api/deno.json | 3 - tests/testdata/run/unstable_temporal_api/main.out | 12 - tests/testdata/run/unstable_temporal_api/main.ts | 71 --- tools/lint.js | 2 +- 21 files changed, 498 insertions(+), 820 deletions(-) create mode 100644 tests/specs/run/unstable_temporal_api/__test__.jsonc create mode 100644 tests/specs/run/unstable_temporal_api/deno.json create mode 100644 tests/specs/run/unstable_temporal_api/main.out create mode 100644 tests/specs/run/unstable_temporal_api/main.ts create mode 100644 tests/specs/run/unstable_temporal_api/missing_flag.js create mode 100644 tests/specs/run/unstable_temporal_api/missing_flag.out create mode 100644 tests/specs/run/unstable_temporal_api_list/__test__.jsonc create mode 100644 tests/specs/run/unstable_temporal_api_list/main.out create mode 100644 tests/specs/run/unstable_temporal_api_list/main.ts create mode 100644 tests/specs/run/unstable_temporal_api_patch/__test__.jsonc create mode 100644 tests/specs/run/unstable_temporal_api_patch/main.out create mode 100644 tests/specs/run/unstable_temporal_api_patch/main.ts delete mode 100644 tests/testdata/run/unstable_temporal_api/deno.json delete mode 100644 tests/testdata/run/unstable_temporal_api/main.out delete mode 100644 tests/testdata/run/unstable_temporal_api/main.ts diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index b826aa1f7..25b3fde9e 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -2067,8 +2067,7 @@ declare namespace Temporal { }; /** - * Options to control behavior of `Duration.compare()`, `Duration.add()`, and - * `Duration.subtract()` + * Options to control behavior of `Duration.compare()` * * @category Temporal * @experimental @@ -2271,9 +2270,6 @@ declare namespace Temporal { | "nanosecond" >, ): Temporal.Instant; - toZonedDateTime( - calendarAndTimeZone: { timeZone: TimeZoneLike; calendar: CalendarLike }, - ): Temporal.ZonedDateTime; toZonedDateTimeISO(tzLike: TimeZoneLike): Temporal.ZonedDateTime; toLocaleString( locales?: string | string[], @@ -2286,356 +2282,19 @@ declare namespace Temporal { } /** - * @category Temporal - * @experimental - */ - export type YearOrEraAndEraYear = { era: string; eraYear: number } | { - year: number; - }; - /** - * @category Temporal - * @experimental - */ - export type MonthCodeOrMonthAndYear = - | (YearOrEraAndEraYear & { month: number }) - | { - monthCode: string; - }; - /** - * @category Temporal - * @experimental - */ - export type MonthOrMonthCode = { month: number } | { monthCode: string }; - - /** - * @category Temporal - * @experimental - */ - export interface CalendarProtocol { - id: string; - year( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | PlainDateLike - | string, - ): number; - month( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | Temporal.PlainMonthDay - | PlainDateLike - | string, - ): number; - monthCode( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | Temporal.PlainMonthDay - | PlainDateLike - | string, - ): string; - day( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainMonthDay - | PlainDateLike - | string, - ): number; - era( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): string | undefined; - eraYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number | undefined; - dayOfWeek( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number; - dayOfYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number; - weekOfYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number | undefined; - yearOfWeek( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number | undefined; - daysInWeek( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number; - daysInMonth( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | PlainDateLike - | string, - ): number; - daysInYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | PlainDateLike - | string, - ): number; - monthsInYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | PlainDateLike - | string, - ): number; - inLeapYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | PlainDateLike - | string, - ): boolean; - dateFromFields( - fields: YearOrEraAndEraYear & MonthOrMonthCode & { day: number }, - options?: AssignmentOptions, - ): Temporal.PlainDate; - yearMonthFromFields( - fields: YearOrEraAndEraYear & MonthOrMonthCode, - options?: AssignmentOptions, - ): Temporal.PlainYearMonth; - monthDayFromFields( - fields: MonthCodeOrMonthAndYear & { day: number }, - options?: AssignmentOptions, - ): Temporal.PlainMonthDay; - dateAdd( - date: Temporal.PlainDate | PlainDateLike | string, - duration: Temporal.Duration | DurationLike | string, - options?: ArithmeticOptions, - ): Temporal.PlainDate; - dateUntil( - one: Temporal.PlainDate | PlainDateLike | string, - two: Temporal.PlainDate | PlainDateLike | string, - options?: DifferenceOptions<"year" | "month" | "week" | "day">, - ): Temporal.Duration; - fields(fields: Iterable): Iterable; - mergeFields( - fields: Record, - additionalFields: Record, - ): Record; - toString?(): string; - toJSON?(): string; - } - - /** - * Any of these types can be passed to Temporal methods instead of a Temporal.Calendar. + * Any of these types can be passed to Temporal methods instead of a calendar ID. * * @category Temporal * @experimental */ export type CalendarLike = | string - | CalendarProtocol | ZonedDateTime | PlainDateTime | PlainDate | PlainYearMonth | PlainMonthDay; - /** - * A `Temporal.Calendar` is a representation of a calendar system. It includes - * information about how many days are in each year, how many months are in - * each year, how many days are in each month, and how to do arithmetic in - * that calendar system. - * - * See https://tc39.es/proposal-temporal/docs/calendar.html for more details. - * - * @category Temporal - * @experimental - */ - export class Calendar implements CalendarProtocol { - static from(item: CalendarLike): Temporal.Calendar | CalendarProtocol; - constructor(calendarIdentifier: string); - readonly id: string; - year( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | PlainDateLike - | string, - ): number; - month( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | Temporal.PlainMonthDay - | PlainDateLike - | string, - ): number; - monthCode( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | Temporal.PlainMonthDay - | PlainDateLike - | string, - ): string; - day( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainMonthDay - | PlainDateLike - | string, - ): number; - era( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): string | undefined; - eraYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number | undefined; - dayOfWeek( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number; - dayOfYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number; - weekOfYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number | undefined; - yearOfWeek( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number | undefined; - daysInWeek( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | PlainDateLike - | string, - ): number; - daysInMonth( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | PlainDateLike - | string, - ): number; - daysInYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | PlainDateLike - | string, - ): number; - monthsInYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | PlainDateLike - | string, - ): number; - inLeapYear( - date: - | Temporal.PlainDate - | Temporal.PlainDateTime - | Temporal.PlainYearMonth - | PlainDateLike - | string, - ): boolean; - dateFromFields( - fields: YearOrEraAndEraYear & MonthOrMonthCode & { day: number }, - options?: AssignmentOptions, - ): Temporal.PlainDate; - yearMonthFromFields( - fields: YearOrEraAndEraYear & MonthOrMonthCode, - options?: AssignmentOptions, - ): Temporal.PlainYearMonth; - monthDayFromFields( - fields: MonthCodeOrMonthAndYear & { day: number }, - options?: AssignmentOptions, - ): Temporal.PlainMonthDay; - dateAdd( - date: Temporal.PlainDate | PlainDateLike | string, - duration: Temporal.Duration | DurationLike | string, - options?: ArithmeticOptions, - ): Temporal.PlainDate; - dateUntil( - one: Temporal.PlainDate | PlainDateLike | string, - two: Temporal.PlainDate | PlainDateLike | string, - options?: DifferenceOptions<"year" | "month" | "week" | "day">, - ): Temporal.Duration; - fields(fields: Iterable): string[]; - mergeFields( - fields: Record, - additionalFields: Record, - ): Record; - toString(): string; - toJSON(): string; - readonly [Symbol.toStringTag]: "Temporal.Calendar"; - } - /** * @category Temporal * @experimental @@ -2650,17 +2309,6 @@ declare namespace Temporal { calendar?: CalendarLike; }; - /** - * @category Temporal - * @experimental - */ - export type PlainDateISOFields = { - isoYear: number; - isoMonth: number; - isoDay: number; - calendar: string | CalendarProtocol; - }; - /** * A `Temporal.PlainDate` represents a calendar date. "Calendar date" refers to the * concept of a date as expressed in everyday usage, independent of any time @@ -2686,7 +2334,7 @@ declare namespace Temporal { isoYear: number, isoMonth: number, isoDay: number, - calendar?: CalendarLike, + calendar?: string, ); readonly era: string | undefined; readonly eraYear: number | undefined; @@ -2731,7 +2379,6 @@ declare namespace Temporal { ): Temporal.PlainDateTime; toZonedDateTime( timeZoneAndTime: - | TimeZoneProtocol | string | { timeZone: TimeZoneLike; @@ -2740,7 +2387,6 @@ declare namespace Temporal { ): Temporal.ZonedDateTime; toPlainYearMonth(): Temporal.PlainYearMonth; toPlainMonthDay(): Temporal.PlainMonthDay; - getISOFields(): PlainDateISOFields; toLocaleString( locales?: string | string[], options?: Intl.DateTimeFormatOptions, @@ -2771,23 +2417,6 @@ declare namespace Temporal { calendar?: CalendarLike; }; - /** - * @category Temporal - * @experimental - */ - export type PlainDateTimeISOFields = { - isoYear: number; - isoMonth: number; - isoDay: number; - isoHour: number; - isoMinute: number; - isoSecond: number; - isoMillisecond: number; - isoMicrosecond: number; - isoNanosecond: number; - calendar: string | CalendarProtocol; - }; - /** * A `Temporal.PlainDateTime` represents a calendar date and wall-clock time, with * a precision in nanoseconds, and without any time zone. Of the Temporal @@ -2820,7 +2449,7 @@ declare namespace Temporal { millisecond?: number, microsecond?: number, nanosecond?: number, - calendar?: CalendarLike, + calendar?: string, ); readonly era: string | undefined; readonly eraYear: number | undefined; @@ -2908,7 +2537,6 @@ declare namespace Temporal { ): Temporal.ZonedDateTime; toPlainDate(): Temporal.PlainDate; toPlainTime(): Temporal.PlainTime; - getISOFields(): PlainDateTimeISOFields; toLocaleString( locales?: string | string[], options?: Intl.DateTimeFormatOptions, @@ -2951,7 +2579,7 @@ declare namespace Temporal { constructor( isoMonth: number, isoDay: number, - calendar?: CalendarLike, + calendar?: string, referenceISOYear?: number, ); readonly monthCode: string; @@ -2963,7 +2591,6 @@ declare namespace Temporal { options?: AssignmentOptions, ): Temporal.PlainMonthDay; toPlainDate(year: { year: number }): Temporal.PlainDate; - getISOFields(): PlainDateISOFields; toLocaleString( locales?: string | string[], options?: Intl.DateTimeFormatOptions, @@ -2987,19 +2614,6 @@ declare namespace Temporal { nanosecond?: number; }; - /** - * @category Temporal - * @experimental - */ - export type PlainTimeISOFields = { - isoHour: number; - isoMinute: number; - isoSecond: number; - isoMillisecond: number; - isoMicrosecond: number; - isoNanosecond: number; - }; - /** * A `Temporal.PlainTime` represents a wall-clock time, with a precision in * nanoseconds, and without any time zone. "Wall-clock time" refers to the @@ -3086,7 +2700,6 @@ declare namespace Temporal { | "nanosecond" >, ): Temporal.PlainTime; - getISOFields(): PlainTimeISOFields; toLocaleString( locales?: string | string[], options?: Intl.DateTimeFormatOptions, @@ -3098,76 +2711,12 @@ declare namespace Temporal { } /** - * A plain object implementing the protocol for a custom time zone. - * - * @category Temporal - * @experimental - */ - export interface TimeZoneProtocol { - id: string; - getOffsetNanosecondsFor(instant: Temporal.Instant | string): number; - getOffsetStringFor?(instant: Temporal.Instant | string): string; - getPlainDateTimeFor?( - instant: Temporal.Instant | string, - calendar?: CalendarLike, - ): Temporal.PlainDateTime; - getInstantFor?( - dateTime: Temporal.PlainDateTime | PlainDateTimeLike | string, - options?: ToInstantOptions, - ): Temporal.Instant; - getPossibleInstantsFor( - dateTime: Temporal.PlainDateTime | PlainDateTimeLike | string, - ): Temporal.Instant[]; - toString?(): string; - toJSON?(): string; - } - - /** - * Any of these types can be passed to Temporal methods instead of a Temporal.TimeZone. + * Any of these types can be passed to Temporal methods instead of a time zone ID. * * @category Temporal * @experimental */ - export type TimeZoneLike = string | TimeZoneProtocol | ZonedDateTime; - - /** - * A `Temporal.TimeZone` is a representation of a time zone: either an - * {@link https://www.iana.org/time-zones|IANA time zone}, including - * information about the time zone such as the offset between the local time - * and UTC at a particular time, and daylight saving time (DST) changes; or - * simply a particular UTC offset with no DST. - * - * `Temporal.ZonedDateTime` is the only Temporal type to contain a time zone. - * Other types, like `Temporal.Instant` and `Temporal.PlainDateTime`, do not - * contain any time zone information, and a `Temporal.TimeZone` object is - * required to convert between them. - * - * See https://tc39.es/proposal-temporal/docs/timezone.html for more details. - * - * @category Temporal - * @experimental - */ - export class TimeZone implements TimeZoneProtocol { - static from(timeZone: TimeZoneLike): Temporal.TimeZone | TimeZoneProtocol; - constructor(timeZoneIdentifier: string); - readonly id: string; - getOffsetNanosecondsFor(instant: Temporal.Instant | string): number; - getOffsetStringFor(instant: Temporal.Instant | string): string; - getPlainDateTimeFor( - instant: Temporal.Instant | string, - calendar?: CalendarLike, - ): Temporal.PlainDateTime; - getInstantFor( - dateTime: Temporal.PlainDateTime | PlainDateTimeLike | string, - options?: ToInstantOptions, - ): Temporal.Instant; - getPossibleInstantsFor( - dateTime: Temporal.PlainDateTime | PlainDateTimeLike | string, - ): Temporal.Instant[]; - toString(): string; - toJSON(): string; - readonly [Symbol.toStringTag]: "Temporal.TimeZone"; - } + export type TimeZoneLike = string | ZonedDateTime; /** * @category Temporal @@ -3204,7 +2753,7 @@ declare namespace Temporal { constructor( isoYear: number, isoMonth: number, - calendar?: CalendarLike, + calendar?: string, referenceISODay?: number, ); readonly era: string | undefined; @@ -3241,7 +2790,6 @@ declare namespace Temporal { options?: DifferenceOptions<"year" | "month">, ): Temporal.Duration; toPlainDate(day: { day: number }): Temporal.PlainDate; - getISOFields(): PlainDateISOFields; toLocaleString( locales?: string | string[], options?: Intl.DateTimeFormatOptions, @@ -3274,25 +2822,6 @@ declare namespace Temporal { calendar?: CalendarLike; }; - /** - * @category Temporal - * @experimental - */ - export type ZonedDateTimeISOFields = { - isoYear: number; - isoMonth: number; - isoDay: number; - isoHour: number; - isoMinute: number; - isoSecond: number; - isoMillisecond: number; - isoMicrosecond: number; - isoNanosecond: number; - offset: string; - timeZone: string | TimeZoneProtocol; - calendar: string | CalendarProtocol; - }; - /** * @category Temporal * @experimental @@ -3306,11 +2835,7 @@ declare namespace Temporal { one: Temporal.ZonedDateTime | ZonedDateTimeLike | string, two: Temporal.ZonedDateTime | ZonedDateTimeLike | string, ): ComparisonResult; - constructor( - epochNanoseconds: bigint, - timeZone: TimeZoneLike, - calendar?: CalendarLike, - ); + constructor(epochNanoseconds: bigint, timeZone: string, calendar?: string); readonly era: string | undefined; readonly eraYear: number | undefined; readonly year: number; @@ -3337,9 +2862,7 @@ declare namespace Temporal { readonly inLeapYear: boolean; readonly offsetNanoseconds: number; readonly offset: string; - readonly epochSeconds: number; readonly epochMilliseconds: number; - readonly epochMicroseconds: bigint; readonly epochNanoseconds: bigint; equals(other: Temporal.ZonedDateTime | ZonedDateTimeLike | string): boolean; with( @@ -3408,7 +2931,6 @@ declare namespace Temporal { toPlainDateTime(): Temporal.PlainDateTime; toPlainDate(): Temporal.PlainDate; toPlainTime(): Temporal.PlainTime; - getISOFields(): ZonedDateTimeISOFields; toLocaleString( locales?: string | string[], options?: Intl.DateTimeFormatOptions, @@ -3449,8 +2971,7 @@ declare namespace Temporal { * * @param {TimeZoneLike} [tzLike] - * {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones|IANA time zone identifier} - * string (e.g. `'Europe/London'`), `Temporal.TimeZone` instance, or an - * object implementing the time zone protocol. If omitted, the environment's + * string (e.g. `'Europe/London'`). If omitted, the environment's * current time zone will be used. */ zonedDateTimeISO: (tzLike?: TimeZoneLike) => Temporal.ZonedDateTime; @@ -3466,8 +2987,7 @@ declare namespace Temporal { * * @param {TimeZoneLike} [tzLike] - * {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones|IANA time zone identifier} - * string (e.g. `'Europe/London'`), `Temporal.TimeZone` instance, or an - * object implementing the time zone protocol. If omitted, the environment's + * string (e.g. `'Europe/London'`). If omitted, the environment's * current time zone will be used. */ plainDateTimeISO: (tzLike?: TimeZoneLike) => Temporal.PlainDateTime; @@ -3478,8 +2998,7 @@ declare namespace Temporal { * * @param {TimeZoneLike} [tzLike] - * {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones|IANA time zone identifier} - * string (e.g. `'Europe/London'`), `Temporal.TimeZone` instance, or an - * object implementing the time zone protocol. If omitted, the environment's + * string (e.g. `'Europe/London'`). If omitted, the environment's * current time zone will be used. */ plainDateISO: (tzLike?: TimeZoneLike) => Temporal.PlainDate; @@ -3489,8 +3008,7 @@ declare namespace Temporal { * * @param {TimeZoneLike} [tzLike] - * {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones|IANA time zone identifier} - * string (e.g. `'Europe/London'`), `Temporal.TimeZone` instance, or an - * object implementing the time zone protocol. If omitted, the environment's + * string (e.g. `'Europe/London'`). If omitted, the environment's * current time zone will be used. */ plainTimeISO: (tzLike?: TimeZoneLike) => Temporal.PlainTime; diff --git a/ext/console/01_console.js b/ext/console/01_console.js index 15c5c837b..761368b57 100644 --- a/ext/console/01_console.js +++ b/ext/console/01_console.js @@ -844,14 +844,6 @@ function formatRaw(ctx, value, recurseTimes, typedArray, proxyDetails) { ObjectPrototypeIsPrototypeOf( globalThis.Temporal.Duration.prototype, value, - ) || - ObjectPrototypeIsPrototypeOf( - globalThis.Temporal.TimeZone.prototype, - value, - ) || - ObjectPrototypeIsPrototypeOf( - globalThis.Temporal.Calendar.prototype, - value, ) ) ) { diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 36f08dce5..0496da9e7 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -23,6 +23,7 @@ import { } from "ext:core/ops"; const { ArrayPrototypeFilter, + ArrayPrototypeForEach, ArrayPrototypeIncludes, ArrayPrototypeMap, DateNow, @@ -35,6 +36,7 @@ const { ObjectDefineProperty, ObjectHasOwn, ObjectKeys, + ObjectGetOwnPropertyDescriptor, ObjectPrototypeIsPrototypeOf, ObjectSetPrototypeOf, PromisePrototypeThen, @@ -747,26 +749,93 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) { // Removes the obsoleted `Temporal` API. // https://github.com/tc39/proposal-temporal/pull/2895 // https://github.com/tc39/proposal-temporal/pull/2914 - if (typeof Temporal.Instant.fromEpochSeconds === "undefined") { + // https://github.com/tc39/proposal-temporal/pull/2925 + if (typeof globalThis.Temporal.Instant.fromEpochSeconds === "undefined") { throw "V8 removes obsoleted Temporal API now, no need to delete them!"; } - delete Temporal.Instant.fromEpochSeconds; - delete Temporal.Instant.fromEpochMicroseconds; - delete Temporal.Instant.prototype.epochSeconds; - delete Temporal.Instant.prototype.epochMicroseconds; - delete Temporal.PlainDateTime.prototype.withPlainDate; - delete Temporal.PlainDateTime.prototype.toPlainYearMonth; - delete Temporal.PlainDateTime.prototype.toPlainMonthDay; - delete Temporal.PlainTime.prototype.toPlainDateTime; - delete Temporal.PlainTime.prototype.toZonedDateTime; - delete Temporal.TimeZone.prototype.getNextTransition; - delete Temporal.TimeZone.prototype.getPreviousTransition; - delete Temporal.ZonedDateTime.prototype.withPlainDate; - delete Temporal.ZonedDateTime.prototype.toPlainYearMonth; - delete Temporal.ZonedDateTime.prototype.toPlainMonthDay; - delete Temporal.Now.zonedDateTime; - delete Temporal.Now.plainDateTime; - delete Temporal.Now.plainDate; + delete globalThis.Temporal.Instant.fromEpochSeconds; + delete globalThis.Temporal.Instant.fromEpochMicroseconds; + delete globalThis.Temporal.Instant.prototype.epochSeconds; + delete globalThis.Temporal.Instant.prototype.epochMicroseconds; + delete globalThis.Temporal.Instant.prototype.toZonedDateTime; + delete globalThis.Temporal.PlainDate.prototype.getISOFiels; // weird + delete globalThis.Temporal.PlainDate.prototype.getISOFields; + delete globalThis.Temporal.PlainDateTime.prototype.withPlainDate; + delete globalThis.Temporal.PlainDateTime.prototype.toPlainYearMonth; + delete globalThis.Temporal.PlainDateTime.prototype.toPlainMonthDay; + delete globalThis.Temporal.PlainDateTime.prototype.getISOFields; + delete globalThis.Temporal.PlainMonthDay.prototype.getISOFields; + delete globalThis.Temporal.PlainTime.prototype.calendar; + delete globalThis.Temporal.PlainTime.prototype.toPlainDateTime; + delete globalThis.Temporal.PlainTime.prototype.toZonedDateTime; + delete globalThis.Temporal.PlainTime.prototype.getISOFields; + delete globalThis.Temporal.PlainYearMonth.prototype.getISOFields; + delete globalThis.Temporal.ZonedDateTime.prototype.epochSeconds; + delete globalThis.Temporal.ZonedDateTime.prototype.epochMicroseconds; + delete globalThis.Temporal.ZonedDateTime.prototype.withPlainDate; + delete globalThis.Temporal.ZonedDateTime.prototype.toPlainYearMonth; + delete globalThis.Temporal.ZonedDateTime.prototype.toPlainMonthDay; + delete globalThis.Temporal.ZonedDateTime.prototype.getISOFields; + delete globalThis.Temporal.Now.zonedDateTime; + delete globalThis.Temporal.Now.plainDateTime; + delete globalThis.Temporal.Now.plainDate; + delete globalThis.Temporal.Calendar; + delete globalThis.Temporal.TimeZone; + + // Modify `Temporal.Calendar` to calendarId string + ArrayPrototypeForEach([ + globalThis.Temporal.PlainDate, + globalThis.Temporal.PlainDateTime, + globalThis.Temporal.PlainMonthDay, + globalThis.Temporal.PlainYearMonth, + globalThis.Temporal.ZonedDateTime, + ], (target) => { + const getCalendar = + ObjectGetOwnPropertyDescriptor(target.prototype, "calendar").get; + ObjectDefineProperty(target.prototype, "calendarId", { + __proto__: null, + get: function calendarId() { + return FunctionPrototypeCall(getCalendar, this).id; + }, + enumerable: false, + configurable: true, + }); + delete target.prototype.calendar; + }); + + // Modify `Temporal.TimeZone` to timeZoneId string + { + const getTimeZone = ObjectGetOwnPropertyDescriptor( + globalThis.Temporal.ZonedDateTime.prototype, + "timeZone", + ).get; + ObjectDefineProperty( + globalThis.Temporal.ZonedDateTime.prototype, + "timeZoneId", + { + __proto__: null, + get: function timeZoneId() { + return FunctionPrototypeCall(getTimeZone, this).id; + }, + enumerable: false, + configurable: true, + }, + ); + delete globalThis.Temporal.ZonedDateTime.prototype.timeZone; + } + { + const nowTimeZone = globalThis.Temporal.Now.timeZone; + ObjectDefineProperty(globalThis.Temporal.Now, "timeZoneId", { + __proto__: null, + value: function timeZoneId() { + return nowTimeZone().id; + }, + writable: true, + enumerable: false, + configurable: true, + }); + delete globalThis.Temporal.Now.timeZone; + } } // Setup `Deno` global - we're actually overriding already existing global @@ -889,26 +958,93 @@ function bootstrapWorkerRuntime( // Removes the obsoleted `Temporal` API. // https://github.com/tc39/proposal-temporal/pull/2895 // https://github.com/tc39/proposal-temporal/pull/2914 - if (typeof Temporal.Instant.fromEpochSeconds === "undefined") { + // https://github.com/tc39/proposal-temporal/pull/2925 + if (typeof globalThis.Temporal.Instant.fromEpochSeconds === "undefined") { throw "V8 removes obsoleted Temporal API now, no need to delete them!"; } - delete Temporal.Instant.fromEpochSeconds; - delete Temporal.Instant.fromEpochMicroseconds; - delete Temporal.Instant.prototype.epochSeconds; - delete Temporal.Instant.prototype.epochMicroseconds; - delete Temporal.PlainDateTime.prototype.withPlainDate; - delete Temporal.PlainDateTime.prototype.toPlainYearMonth; - delete Temporal.PlainDateTime.prototype.toPlainMonthDay; - delete Temporal.PlainTime.prototype.toPlainDateTime; - delete Temporal.PlainTime.prototype.toZonedDateTime; - delete Temporal.TimeZone.prototype.getNextTransition; - delete Temporal.TimeZone.prototype.getPreviousTransition; - delete Temporal.ZonedDateTime.prototype.withPlainDate; - delete Temporal.ZonedDateTime.prototype.toPlainYearMonth; - delete Temporal.ZonedDateTime.prototype.toPlainMonthDay; - delete Temporal.Now.zonedDateTime; - delete Temporal.Now.plainDateTime; - delete Temporal.Now.plainDate; + delete globalThis.Temporal.Instant.fromEpochSeconds; + delete globalThis.Temporal.Instant.fromEpochMicroseconds; + delete globalThis.Temporal.Instant.prototype.epochSeconds; + delete globalThis.Temporal.Instant.prototype.epochMicroseconds; + delete globalThis.Temporal.Instant.prototype.toZonedDateTime; + delete globalThis.Temporal.PlainDate.prototype.getISOFiels; // weird + delete globalThis.Temporal.PlainDate.prototype.getISOFields; + delete globalThis.Temporal.PlainDateTime.prototype.withPlainDate; + delete globalThis.Temporal.PlainDateTime.prototype.toPlainYearMonth; + delete globalThis.Temporal.PlainDateTime.prototype.toPlainMonthDay; + delete globalThis.Temporal.PlainDateTime.prototype.getISOFields; + delete globalThis.Temporal.PlainMonthDay.prototype.getISOFields; + delete globalThis.Temporal.PlainTime.prototype.calendar; + delete globalThis.Temporal.PlainTime.prototype.toPlainDateTime; + delete globalThis.Temporal.PlainTime.prototype.toZonedDateTime; + delete globalThis.Temporal.PlainTime.prototype.getISOFields; + delete globalThis.Temporal.PlainYearMonth.prototype.getISOFields; + delete globalThis.Temporal.ZonedDateTime.prototype.epochSeconds; + delete globalThis.Temporal.ZonedDateTime.prototype.epochMicroseconds; + delete globalThis.Temporal.ZonedDateTime.prototype.withPlainDate; + delete globalThis.Temporal.ZonedDateTime.prototype.toPlainYearMonth; + delete globalThis.Temporal.ZonedDateTime.prototype.toPlainMonthDay; + delete globalThis.Temporal.ZonedDateTime.prototype.getISOFields; + delete globalThis.Temporal.Now.zonedDateTime; + delete globalThis.Temporal.Now.plainDateTime; + delete globalThis.Temporal.Now.plainDate; + delete globalThis.Temporal.Calendar; + delete globalThis.Temporal.TimeZone; + + // Modify `Temporal.Calendar` to calendarId string + ArrayPrototypeForEach([ + globalThis.Temporal.PlainDate, + globalThis.Temporal.PlainDateTime, + globalThis.Temporal.PlainMonthDay, + globalThis.Temporal.PlainYearMonth, + globalThis.Temporal.ZonedDateTime, + ], (target) => { + const getCalendar = + ObjectGetOwnPropertyDescriptor(target.prototype, "calendar").get; + ObjectDefineProperty(target.prototype, "calendarId", { + __proto__: null, + get: function calendarId() { + return FunctionPrototypeCall(getCalendar, this).id; + }, + enumerable: false, + configurable: true, + }); + delete target.prototype.calendar; + }); + + // Modify `Temporal.TimeZone` to timeZoneId string + { + const getTimeZone = ObjectGetOwnPropertyDescriptor( + globalThis.Temporal.ZonedDateTime.prototype, + "timeZone", + ).get; + ObjectDefineProperty( + globalThis.Temporal.ZonedDateTime.prototype, + "timeZoneId", + { + __proto__: null, + get: function timeZoneId() { + return FunctionPrototypeCall(getTimeZone, this).id; + }, + enumerable: false, + configurable: true, + }, + ); + delete globalThis.Temporal.ZonedDateTime.prototype.timeZone; + } + { + const nowTimeZone = globalThis.Temporal.Now.timeZone; + ObjectDefineProperty(globalThis.Temporal.Now, "timeZoneId", { + __proto__: null, + value: function timeZoneId() { + return nowTimeZone().id; + }, + writable: true, + enumerable: false, + configurable: true, + }); + delete globalThis.Temporal.Now.timeZone; + } } // Setup `Deno` global - we're actually overriding already existing global diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 8fb64defd..f0d0a2d8d 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -11111,24 +11111,6 @@ fn lsp_workspace_symbol() { }, "containerName": "B" }, - { - "name": "fields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "CalendarProtocol" - }, - { - "name": "fields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Calendar" - }, { "name": "ClassFieldDecoratorContext", "kind": 11, @@ -11138,168 +11120,6 @@ fn lsp_workspace_symbol() { }, "containerName": "" }, - { - "name": "dateFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "CalendarProtocol" - }, - { - "name": "dateFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Calendar" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "PlainDate" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "PlainDateTime" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "PlainMonthDay" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "PlainTime" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "PlainYearMonth" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "ZonedDateTime" - }, - { - "name": "mergeFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "CalendarProtocol" - }, - { - "name": "mergeFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Calendar" - }, - { - "name": "monthDayFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "CalendarProtocol" - }, - { - "name": "monthDayFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Calendar" - }, - { - "name": "PlainDateISOFields", - "kind": 5, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Temporal" - }, - { - "name": "PlainDateTimeISOFields", - "kind": 5, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Temporal" - }, - { - "name": "PlainTimeISOFields", - "kind": 5, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Temporal" - }, - { - "name": "yearMonthFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "CalendarProtocol" - }, - { - "name": "yearMonthFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Calendar" - }, - { - "name": "ZonedDateTimeISOFields", - "kind": 5, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Temporal" - } ]) ); client.shutdown(); diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index 9a680b944..6f85aaf0b 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -4731,20 +4731,6 @@ itest!(unsafe_proto_flag { exit_code: 0, }); -itest!(unstable_temporal_api { - args: "run --no-config --unstable-temporal --check run/unstable_temporal_api/main.ts", - output: "run/unstable_temporal_api/main.out", - http_server: false, - exit_code: 0, -}); - -itest!(unstable_temporal_api_config_file { - args: "run --check run/unstable_temporal_api/main.ts", - output: "run/unstable_temporal_api/main.out", - http_server: false, - exit_code: 0, -}); - // TODO(bartlomieju): temporary disabled // itest!(warn_on_deprecated_api { // args: "run -A run/warn_on_deprecated_api/main.js", diff --git a/tests/specs/run/unstable_temporal_api/__test__.jsonc b/tests/specs/run/unstable_temporal_api/__test__.jsonc new file mode 100644 index 000000000..226e0ce04 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/__test__.jsonc @@ -0,0 +1,19 @@ +{ + "tests": { + "basic": { + "args": "run --no-config --unstable-temporal --check main.ts", + "output": "main.out", + "exitCode": 0 + }, + "config": { + "args": "run --unstable-temporal --check main.ts", + "output": "main.out", + "exitCode": 0 + }, + "missing_flag": { + "args": "run --no-config missing_flag.js", + "output": "missing_flag.out", + "exitCode": 1 + } + } +} diff --git a/tests/specs/run/unstable_temporal_api/deno.json b/tests/specs/run/unstable_temporal_api/deno.json new file mode 100644 index 000000000..fea0791c5 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/deno.json @@ -0,0 +1,3 @@ +{ + "unstable": ["temporal"] +} diff --git a/tests/specs/run/unstable_temporal_api/main.out b/tests/specs/run/unstable_temporal_api/main.out new file mode 100644 index 000000000..d916a4cc2 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/main.out @@ -0,0 +1,10 @@ +Check [WILDCARD] +Temporal.Now [WILDCARD] +Temporal.Instant 1969-07-20T20:17:00Z +Temporal.ZonedDateTime 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles] +Temporal.PlainDate 2006-08-24 +Temporal.PlainTime 19:39:09.068346205 +Temporal.PlainDateTime 1995-12-07T15:00:00 +Temporal.PlainYearMonth 2020-10 +Temporal.PlainMonthDay 07-14 +Temporal.Duration PT130H20M diff --git a/tests/specs/run/unstable_temporal_api/main.ts b/tests/specs/run/unstable_temporal_api/main.ts new file mode 100644 index 000000000..351b30e7d --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/main.ts @@ -0,0 +1,59 @@ +console.log("Temporal.Now", Temporal.Now.instant()); +console.log( + "Temporal.Instant", + Temporal.Instant.from("1969-07-20T20:17Z"), +); +console.log( + "Temporal.ZonedDateTime", + Temporal.ZonedDateTime.from({ + timeZone: "America/Los_Angeles", + year: 1995, + month: 12, + day: 7, + hour: 3, + minute: 24, + second: 30, + millisecond: 0, + microsecond: 3, + nanosecond: 500, + }), +); +console.log( + "Temporal.PlainDate", + Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }), +); +console.log( + "Temporal.PlainTime", + Temporal.PlainTime.from({ + hour: 19, + minute: 39, + second: 9, + millisecond: 68, + microsecond: 346, + nanosecond: 205, + }), +); +console.log( + "Temporal.PlainDateTime", + Temporal.PlainDateTime.from({ + year: 1995, + month: 12, + day: 7, + hour: 15, + }), +); +console.log( + "Temporal.PlainYearMonth", + Temporal.PlainYearMonth.from({ year: 2020, month: 10 }), +); +console.log( + "Temporal.PlainMonthDay", + Temporal.PlainMonthDay.from({ month: 7, day: 14 }), +); +console.log( + "Temporal.Duration", + Temporal.Duration.from({ + hours: 130, + minutes: 20, + }), +); diff --git a/tests/specs/run/unstable_temporal_api/missing_flag.js b/tests/specs/run/unstable_temporal_api/missing_flag.js new file mode 100644 index 000000000..92aed7931 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/missing_flag.js @@ -0,0 +1 @@ +Temporal.Now.instant(); diff --git a/tests/specs/run/unstable_temporal_api/missing_flag.out b/tests/specs/run/unstable_temporal_api/missing_flag.out new file mode 100644 index 000000000..03ed5abb9 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/missing_flag.out @@ -0,0 +1,7 @@ +error: Uncaught (in promise) ReferenceError: Temporal is not defined +Temporal.Now.instant(); +^ + at [WILDCARD]missing_flag.js:1:1 + + info: Temporal is an unstable API. + hint: Run again with `--unstable-temporal` flag to enable this API. diff --git a/tests/specs/run/unstable_temporal_api_list/__test__.jsonc b/tests/specs/run/unstable_temporal_api_list/__test__.jsonc new file mode 100644 index 000000000..b5b12ed26 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_list/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --no-config --unstable-temporal --check main.ts", + "output": "main.out", + "exitCode": 0 +} diff --git a/tests/specs/run/unstable_temporal_api_list/main.out b/tests/specs/run/unstable_temporal_api_list/main.out new file mode 100644 index 000000000..bdfeab5ac --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_list/main.out @@ -0,0 +1,148 @@ +Check [WILDCARD] +Temporal +[ + "Duration", + "Instant", + "Now", + "PlainDate", + "PlainDateTime", + "PlainMonthDay", + "PlainTime", + "PlainYearMonth", + "ZonedDateTime" +] +Temporal.Now +[ + "instant", + "plainDateISO", + "plainDateTimeISO", + "plainTimeISO", + "timeZoneId", + "zonedDateTimeISO" +] +Temporal.Instant.prototype +[ + "add", + "constructor", + "epochMilliseconds", + "epochNanoseconds", + "equals", + "round", + "since", + "subtract", + "toJSON", + "toLocaleString", + "toString", + "toZonedDateTimeISO", + "until", + "valueOf" +] +Temporal.ZonedDateTime.prototype +[ + "add", "calendarId", "constructor", + "day", "dayOfWeek", "dayOfYear", + "daysInMonth", "daysInWeek", "daysInYear", + "epochMilliseconds", "epochNanoseconds", "equals", + "era", "eraYear", "hour", + "hoursInDay", "inLeapYear", "microsecond", + "millisecond", "minute", "month", + "monthCode", "monthsInYear", "nanosecond", + "offset", "offsetNanoseconds", "round", + "second", "since", "startOfDay", + "subtract", "timeZoneId", "toInstant", + "toJSON", "toLocaleString", "toPlainDate", + "toPlainDateTime", "toPlainTime", "toString", + "until", "valueOf", "weekOfYear", + "with", "withCalendar", "withPlainTime", + "withTimeZone", "year" +] +Temporal.PlainDate.prototype +[ + "add", "calendarId", + "constructor", "day", + "dayOfWeek", "dayOfYear", + "daysInMonth", "daysInWeek", + "daysInYear", "equals", + "era", "eraYear", + "inLeapYear", "month", + "monthCode", "monthsInYear", + "since", "subtract", + "toJSON", "toLocaleString", + "toPlainDateTime", "toPlainMonthDay", + "toPlainYearMonth", "toString", + "toZonedDateTime", "until", + "valueOf", "weekOfYear", + "with", "withCalendar", + "year" +] +Temporal.PlainTime.prototype +[ + "add", "constructor", + "equals", "hour", + "microsecond", "millisecond", + "minute", "nanosecond", + "round", "second", + "since", "subtract", + "toJSON", "toLocaleString", + "toString", "until", + "valueOf", "with" +] +Temporal.PlainDateTime.prototype +[ + "add", "calendarId", "constructor", + "day", "dayOfWeek", "dayOfYear", + "daysInMonth", "daysInWeek", "daysInYear", + "equals", "era", "eraYear", + "hour", "inLeapYear", "microsecond", + "millisecond", "minute", "month", + "monthCode", "monthsInYear", "nanosecond", + "round", "second", "since", + "subtract", "toJSON", "toLocaleString", + "toPlainDate", "toPlainTime", "toString", + "toZonedDateTime", "until", "valueOf", + "weekOfYear", "with", "withCalendar", + "withPlainTime", "year" +] +Temporal.PlainYearMonth.prototype +[ + "add", "calendarId", + "constructor", "daysInMonth", + "daysInYear", "equals", + "era", "eraYear", + "inLeapYear", "month", + "monthCode", "monthsInYear", + "since", "subtract", + "toJSON", "toLocaleString", + "toPlainDate", "toString", + "until", "valueOf", + "with", "year" +] +Temporal.PlainMonthDay.prototype +[ + "calendarId", + "constructor", + "day", + "equals", + "monthCode", + "toJSON", + "toLocaleString", + "toPlainDate", + "toString", + "valueOf", + "with" +] +Temporal.Duration.prototype +[ + "abs", "add", + "blank", "constructor", + "days", "hours", + "microseconds", "milliseconds", + "minutes", "months", + "nanoseconds", "negated", + "round", "seconds", + "sign", "subtract", + "toJSON", "toLocaleString", + "toString", "total", + "valueOf", "weeks", + "with", "years" +] diff --git a/tests/specs/run/unstable_temporal_api_list/main.ts b/tests/specs/run/unstable_temporal_api_list/main.ts new file mode 100644 index 000000000..548bb320a --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_list/main.ts @@ -0,0 +1,37 @@ +console.log("Temporal"); +console.log(Object.getOwnPropertyNames(Temporal).sort()); + +console.log("Temporal.Now"); +console.log(Object.getOwnPropertyNames(Temporal.Now).sort()); + +console.log("Temporal.Instant.prototype"); +console.log(Object.getOwnPropertyNames(Temporal.Instant.prototype).sort()); + +console.log("Temporal.ZonedDateTime.prototype"); +console.log( + Object.getOwnPropertyNames(Temporal.ZonedDateTime.prototype).sort(), +); + +console.log("Temporal.PlainDate.prototype"); +console.log(Object.getOwnPropertyNames(Temporal.PlainDate.prototype).sort()); + +console.log("Temporal.PlainTime.prototype"); +console.log(Object.getOwnPropertyNames(Temporal.PlainTime.prototype).sort()); + +console.log("Temporal.PlainDateTime.prototype"); +console.log( + Object.getOwnPropertyNames(Temporal.PlainDateTime.prototype).sort(), +); + +console.log("Temporal.PlainYearMonth.prototype"); +console.log( + Object.getOwnPropertyNames(Temporal.PlainYearMonth.prototype).sort(), +); + +console.log("Temporal.PlainMonthDay.prototype"); +console.log( + Object.getOwnPropertyNames(Temporal.PlainMonthDay.prototype).sort(), +); + +console.log("Temporal.Duration.prototype"); +console.log(Object.getOwnPropertyNames(Temporal.Duration.prototype).sort()); diff --git a/tests/specs/run/unstable_temporal_api_patch/__test__.jsonc b/tests/specs/run/unstable_temporal_api_patch/__test__.jsonc new file mode 100644 index 000000000..b5b12ed26 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_patch/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --no-config --unstable-temporal --check main.ts", + "output": "main.out", + "exitCode": 0 +} diff --git a/tests/specs/run/unstable_temporal_api_patch/main.out b/tests/specs/run/unstable_temporal_api_patch/main.out new file mode 100644 index 000000000..a17d3a9e2 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_patch/main.out @@ -0,0 +1,7 @@ +Check [WILDCARD] +[WILDCARD] +undefined +iso8601 +UTC +undefined +undefined diff --git a/tests/specs/run/unstable_temporal_api_patch/main.ts b/tests/specs/run/unstable_temporal_api_patch/main.ts new file mode 100644 index 000000000..6a4078053 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_patch/main.ts @@ -0,0 +1,11 @@ +console.log(Temporal.Now.timeZoneId()); +// @ts-expect-error: undefined check +console.log(Temporal.Now.timeZone); + +const zoned = new Temporal.ZonedDateTime(0n, "UTC"); +console.log(zoned.calendarId); +console.log(zoned.timeZoneId); +// @ts-expect-error: undefined check +console.log(zoned.calendar); +// @ts-expect-error: undefined check +console.log(zoned.timeZone); diff --git a/tests/testdata/run/unstable_temporal_api/deno.json b/tests/testdata/run/unstable_temporal_api/deno.json deleted file mode 100644 index fea0791c5..000000000 --- a/tests/testdata/run/unstable_temporal_api/deno.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "unstable": ["temporal"] -} diff --git a/tests/testdata/run/unstable_temporal_api/main.out b/tests/testdata/run/unstable_temporal_api/main.out deleted file mode 100644 index 46d25c3ea..000000000 --- a/tests/testdata/run/unstable_temporal_api/main.out +++ /dev/null @@ -1,12 +0,0 @@ -Check [WILDCARD] -Temporal.Now [WILDCARD] -Temporal.Instant 1969-07-20T20:17:00Z -Temporal.ZonedDateTime 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles] -Temporal.PlainDate 2006-08-24 -Temporal.PlainTime 19:39:09.068346205 -Temporal.PlainDateTime 1995-12-07T15:00:00 -Temporal.PlainYearMonth 2020-10 -Temporal.PlainMonthDay 07-14 -Temporal.Duration PT130H20M -Temporal.TimeZone Africa/Cairo -Temporal.Calendar 1999-12-31 diff --git a/tests/testdata/run/unstable_temporal_api/main.ts b/tests/testdata/run/unstable_temporal_api/main.ts deleted file mode 100644 index 1641b90bf..000000000 --- a/tests/testdata/run/unstable_temporal_api/main.ts +++ /dev/null @@ -1,71 +0,0 @@ -console.log("Temporal.Now", Temporal.Now.instant()); -console.log( - "Temporal.Instant", - Temporal.Instant.from("1969-07-20T20:17Z"), -); -console.log( - "Temporal.ZonedDateTime", - Temporal.ZonedDateTime.from({ - timeZone: "America/Los_Angeles", - year: 1995, - month: 12, - day: 7, - hour: 3, - minute: 24, - second: 30, - millisecond: 0, - microsecond: 3, - nanosecond: 500, - }), -); -console.log( - "Temporal.PlainDate", - Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }), -); -console.log( - "Temporal.PlainTime", - Temporal.PlainTime.from({ - hour: 19, - minute: 39, - second: 9, - millisecond: 68, - microsecond: 346, - nanosecond: 205, - }), -); -console.log( - "Temporal.PlainDateTime", - Temporal.PlainDateTime.from({ - year: 1995, - month: 12, - day: 7, - hour: 15, - }), -); -console.log( - "Temporal.PlainYearMonth", - Temporal.PlainYearMonth.from({ year: 2020, month: 10 }), -); -console.log( - "Temporal.PlainMonthDay", - Temporal.PlainMonthDay.from({ month: 7, day: 14 }), -); -console.log( - "Temporal.Duration", - Temporal.Duration.from({ - hours: 130, - minutes: 20, - }), -); -console.log( - "Temporal.TimeZone", - Temporal.TimeZone.from("Africa/Cairo"), -); -console.log( - "Temporal.Calendar", - Temporal.Calendar.from("iso8601").dateFromFields({ - year: 1999, - month: 12, - day: 31, - }, {}), -); diff --git a/tools/lint.js b/tools/lint.js index db4b657af..2178d4579 100755 --- a/tools/lint.js +++ b/tools/lint.js @@ -220,7 +220,7 @@ async function ensureNoNewITests() { "pm_tests.rs": 0, "publish_tests.rs": 0, "repl_tests.rs": 0, - "run_tests.rs": 340, + "run_tests.rs": 338, "shared_library_tests.rs": 0, "task_tests.rs": 30, "test_tests.rs": 74, -- cgit v1.2.3