Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 22 additions & 15 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const jsxOptionMap = new Map(Object.entries({
export const inverseJsxOptionMap: Map<string, string> = new Map(mapIterator(jsxOptionMap.entries(), ([key, value]: [string, JsxEmit]) => ["" + value, key] as const));

// NOTE: The order here is important to default lib ordering as entries will have the same
// order in the generated program (see `getDefaultLibPriority` in program.ts). This
// order in the generated program (see `getDefaultLibFilePriority` in program.ts). This
// order also affects overload resolution when a type declared in one lib is
// augmented in another lib.
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
Expand All @@ -163,6 +163,7 @@ const libEntries: [string, string][] = [
["es2022", "lib.es2022.d.ts"],
["es2023", "lib.es2023.d.ts"],
["es2024", "lib.es2024.d.ts"],
["es2025", "lib.es2025.d.ts"],
["esnext", "lib.esnext.d.ts"],
// Host only
["dom", "lib.dom.d.ts"],
Expand All @@ -173,7 +174,7 @@ const libEntries: [string, string][] = [
["webworker.iterable", "lib.webworker.iterable.d.ts"],
["webworker.asynciterable", "lib.webworker.asynciterable.d.ts"],
["scripthost", "lib.scripthost.d.ts"],
// ES2015 Or ESNext By-feature options
// ES2015 and later By-feature options
["es2015.core", "lib.es2015.core.d.ts"],
["es2015.collection", "lib.es2015.collection.d.ts"],
["es2015.generator", "lib.es2015.generator.d.ts"],
Expand Down Expand Up @@ -230,27 +231,33 @@ const libEntries: [string, string][] = [
["es2024.regexp", "lib.es2024.regexp.d.ts"],
["es2024.sharedmemory", "lib.es2024.sharedmemory.d.ts"],
["es2024.string", "lib.es2024.string.d.ts"],
["esnext.array", "lib.es2023.array.d.ts"],
["esnext.collection", "lib.esnext.collection.d.ts"],
["esnext.symbol", "lib.es2019.symbol.d.ts"],
["es2025.collection", "lib.es2025.collection.d.ts"],
["es2025.float16", "lib.es2025.float16.d.ts"],
["es2025.intl", "lib.es2025.intl.d.ts"],
["es2025.iterator", "lib.es2025.iterator.d.ts"],
["es2025.promise", "lib.es2025.promise.d.ts"],
["es2025.regexp", "lib.es2025.regexp.d.ts"],
// Fallback for backward compatibility
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
["esnext.intl", "lib.esnext.intl.d.ts"],
["esnext.disposable", "lib.esnext.disposable.d.ts"],
["esnext.symbol", "lib.es2019.symbol.d.ts"],
["esnext.bigint", "lib.es2020.bigint.d.ts"],
["esnext.string", "lib.es2022.string.d.ts"],
["esnext.promise", "lib.es2024.promise.d.ts"],
["esnext.weakref", "lib.es2021.weakref.d.ts"],
["esnext.decorators", "lib.esnext.decorators.d.ts"],
["esnext.object", "lib.es2024.object.d.ts"],
["esnext.array", "lib.esnext.array.d.ts"],
["esnext.regexp", "lib.es2024.regexp.d.ts"],
["esnext.string", "lib.es2024.string.d.ts"],
["esnext.iterator", "lib.esnext.iterator.d.ts"],
["esnext.promise", "lib.esnext.promise.d.ts"],
["esnext.float16", "lib.esnext.float16.d.ts"],
["esnext.typedarrays", "lib.esnext.typedarrays.d.ts"],
["esnext.collection", "lib.es2025.collection.d.ts"],
["esnext.float16", "lib.es2025.float16.d.ts"],
["esnext.iterator", "lib.es2025.iterator.d.ts"],
["esnext.promise", "lib.es2025.promise.d.ts"],
// ESNext By-feature options
["esnext.array", "lib.esnext.array.d.ts"],
["esnext.decorators", "lib.esnext.decorators.d.ts"],
["esnext.disposable", "lib.esnext.disposable.d.ts"],
["esnext.error", "lib.esnext.error.d.ts"],
["esnext.intl", "lib.esnext.intl.d.ts"],
["esnext.sharedmemory", "lib.esnext.sharedmemory.d.ts"],
["esnext.typedarrays", "lib.esnext.typedarrays.d.ts"],
Comment on lines +253 to +259
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are none of these applicable to ES2025?

Copy link
Contributor Author

@petamoriken petamoriken Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

ref: https://github.com/tc39/proposals/blob/main/finished-proposals.md

// Decorators
["decorators", "lib.decorators.d.ts"],
["decorators.legacy", "lib.decorators.legacy.d.ts"],
];
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7672,10 +7672,11 @@ export const enum ScriptTarget {
ES2022 = 9,
ES2023 = 10,
ES2024 = 11,
ES2025 = 12,
ESNext = 99,
JSON = 100,
Latest = ESNext,
LatestStandard = ES2024,
LatestStandard = ES2025,
}

export const enum LanguageVariant {
Expand Down
42 changes: 38 additions & 4 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,11 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
"unicodeSets",
],
})),
RegExpConstructor: new Map(Object.entries({
es2025: [
"escape",
],
})),
Reflect: new Map(Object.entries({
es2015: [
"apply",
Expand Down Expand Up @@ -1565,7 +1570,7 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
"fround",
"cbrt",
],
esnext: [
es2025: [
"f16round",
],
})),
Expand All @@ -1587,7 +1592,7 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
"keys",
"values",
],
esnext: [
es2025: [
"union",
"intersection",
"difference",
Expand All @@ -1613,6 +1618,9 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
es2024: [
"withResolvers",
],
es2025: [
"try",
],
})),
Symbol: new Map(Object.entries({
es2015: [
Expand Down Expand Up @@ -1714,6 +1722,21 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
es2018: [
"PluralRules",
],
es2020: [
"RelativeTimeFormat",
"Locale",
"DisplayNames",
],
es2021: [
"ListFormat",
"DateTimeFormat",
],
es2022: [
"Segmenter",
],
es2025: [
"DurationFormat",
],
})),
NumberFormat: new Map(Object.entries({
es2018: [
Expand All @@ -1737,7 +1760,7 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
"getBigInt64",
"getBigUint64",
],
esnext: [
es2025: [
"setFloat16",
"getFloat16",
],
Expand Down Expand Up @@ -1850,7 +1873,7 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
],
})),
Float16Array: new Map(Object.entries({
esnext: emptyArray,
es2025: emptyArray,
})),
Float32Array: new Map(Object.entries({
es2022: [
Expand Down Expand Up @@ -1911,12 +1934,23 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
"cause",
],
})),
ErrorConstructor: new Map(Object.entries({
esnext: [
"isError",
],
})),
Uint8ArrayConstructor: new Map(Object.entries({
esnext: [
"fromBase64",
"fromHex",
],
})),
DisposableStack: new Map(Object.entries({
esnext: emptyArray,
})),
AsyncDisposableStack: new Map(Object.entries({
esnext: emptyArray,
})),
}))
);

Expand Down
2 changes: 2 additions & 0 deletions src/compiler/utilitiesPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ export function sortAndDeduplicateDiagnostics<T extends Diagnostic>(diagnostics:
// compiler/utilitiesPublic.ts, and the contents of each lib/esnext.*.d.ts file.
export const targetToLibMap: Map<ScriptTarget, string> = new Map([
[ScriptTarget.ESNext, "lib.esnext.full.d.ts"],
[ScriptTarget.ES2025, "lib.es2025.full.d.ts"],
[ScriptTarget.ES2024, "lib.es2024.full.d.ts"],
[ScriptTarget.ES2023, "lib.es2023.full.d.ts"],
[ScriptTarget.ES2022, "lib.es2022.full.d.ts"],
Expand All @@ -327,6 +328,7 @@ export function getDefaultLibFileName(options: CompilerOptions): string {
const target = getEmitScriptTarget(options);
switch (target) {
case ScriptTarget.ESNext:
case ScriptTarget.ES2025:
case ScriptTarget.ES2024:
case ScriptTarget.ES2023:
case ScriptTarget.ES2022:
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions src/lib/es2025.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference lib="es2024" />
/// <reference lib="es2025.collection" />
/// <reference lib="es2025.float16" />
/// <reference lib="es2025.intl" />
/// <reference lib="es2025.iterator" />
/// <reference lib="es2025.promise" />
/// <reference lib="es2025.regexp" />
File renamed without changes.
6 changes: 6 additions & 0 deletions src/lib/es2025.full.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// <reference lib="es2025" />
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not strictly required anymore (for any of the libs), but not a problem in this PR; can be cleaned up later.

134 changes: 134 additions & 0 deletions src/lib/es2025.intl.d.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern with this file is the defined unions they don't entirely match the pattern of inlining things like in existing intl or the original es5 types.

Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/// <reference lib="es2018.intl" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this because NumberFormatPartTypes is being used within the file.


declare namespace Intl {
/**
* An object representing the relative time format in parts
* that can be used for custom locale-aware formatting.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts).
*/
type DurationFormatPart =
| {
type: "literal";
value: string;
unit?: "year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "milliseconds" | "microseconds" | "nanoseconds";
}
| {
type: Exclude<NumberFormatPartTypes, "literal">;
value: string;
unit: "year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "milliseconds" | "microseconds" | "nanoseconds";
};

/**
* An object with some or all properties of the `Intl.DurationFormat` constructor `options` parameter.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#parameters)
*/
interface DurationFormatOptions {
localeMatcher?: "lookup" | "best fit" | undefined;
numberingSystem?: string | undefined;
style?: "long" | "short" | "narrow" | "digital" | undefined;
years?: "long" | "short" | "narrow" | undefined;
yearsDisplay?: "always" | "auto" | undefined;
months?: "long" | "short" | "narrow" | undefined;
monthsDisplay?: "always" | "auto" | undefined;
weeks?: "long" | "short" | "narrow" | undefined;
weeksDisplay?: "always" | "auto" | undefined;
days?: "long" | "short" | "narrow" | undefined;
daysDisplay?: "always" | "auto" | undefined;
hours?: "long" | "short" | "narrow" | "numeric" | "2-digit" | undefined;
hoursDisplay?: "always" | "auto" | undefined;
minutes?: "long" | "short" | "narrow" | "numeric" | "2-digit" | undefined;
minutesDisplay?: "always" | "auto" | undefined;
seconds?: "long" | "short" | "narrow" | "numeric" | "2-digit" | undefined;
secondsDisplay?: "always" | "auto" | undefined;
milliseconds?: "long" | "short" | "narrow" | "numeric" | undefined;
millisecondsDisplay?: "always" | "auto" | undefined;
microseconds?: "long" | "short" | "narrow" | "numeric" | undefined;
microsecondsDisplay?: "always" | "auto" | undefined;
nanoseconds?: "long" | "short" | "narrow" | "numeric" | undefined;
nanosecondsDisplay?: "always" | "auto" | undefined;
fractionalDigits?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
}

/**
* The Intl.DurationFormat object enables language-sensitive duration formatting.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat)
*/
interface DurationFormat {
/**
* @param duration The duration object to be formatted. It should include some or all of the following properties: months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format).
*/
format(duration: Partial<Record<"years" | "months" | "weeks" | "days" | "hours" | "minutes" | "seconds" | "milliseconds" | "microseconds" | "nanoseconds", number>>): string;
/**
* @param duration The duration object to be formatted. It should include some or all of the following properties: months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts).
*/
formatToParts(duration: Partial<Record<"years" | "months" | "weeks" | "days" | "hours" | "minutes" | "seconds" | "milliseconds" | "microseconds" | "nanoseconds", number>>): DurationFormatPart[];
/**
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions).
*/
resolvedOptions(): ResolvedDurationFormatOptions;
}

interface ResolvedDurationFormatOptions {
locale: string;
numberingSystem: string;
style: "long" | "short" | "narrow" | "digital";
years: "long" | "short" | "narrow";
yearsDisplay: "always" | "auto";
months: "long" | "short" | "narrow";
monthsDisplay: "always" | "auto";
weeks: "long" | "short" | "narrow";
weeksDisplay: "always" | "auto";
days: "long" | "short" | "narrow";
daysDisplay: "always" | "auto";
hours: "long" | "short" | "narrow" | "numeric" | "2-digit";
hoursDisplay: "always" | "auto";
minutes: "long" | "short" | "narrow" | "numeric" | "2-digit";
minutesDisplay: "always" | "auto";
seconds: "long" | "short" | "narrow" | "numeric" | "2-digit";
secondsDisplay: "always" | "auto";
milliseconds: "long" | "short" | "narrow" | "numeric";
millisecondsDisplay: "always" | "auto";
microseconds: "long" | "short" | "narrow" | "numeric";
microsecondsDisplay: "always" | "auto";
nanoseconds: "long" | "short" | "narrow" | "numeric";
nanosecondsDisplay: "always" | "auto";
fractionalDigits?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the spec, this fractionalDigits property seems to be optional in the return value of resolvedOptions. I tested the behavior in Chrome and Firefox, and the property was non-existent when it was undefined.

}

const DurationFormat: {
prototype: DurationFormat;

/**
* @param locales A string with a BCP 47 language tag, or an array of such strings.
* For the general form and interpretation of the `locales` argument, see the [Intl](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation)
* page.
*
* @param options An object for setting up a duration format.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat).
*/
new (locales?: LocalesArgument, options?: DurationFormatOptions): DurationFormat;

/**
* Returns an array containing those of the provided locales that are supported in display names without having to fall back to the runtime's default locale.
*
* @param locales A string with a BCP 47 language tag, or an array of such strings.
* For the general form and interpretation of the `locales` argument, see the [Intl](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation)
* page.
*
* @param options An object with a locale matcher.
*
* @returns An array of strings representing a subset of the given locale tags that are supported in display names without having to fall back to the runtime's default locale.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/supportedLocalesOf).
*/
supportedLocalesOf(locales?: LocalesArgument, options?: Pick<DurationFormatOptions, "localeMatcher">): UnicodeBCP47LocaleIdentifier[];
};
}
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions src/lib/es2025.regexp.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
interface RegExpConstructor {
/**
* Escapes any RegExp syntax characters in the input string, returning a
* new string that can be safely interpolated into a RegExp as a literal
* string to match.
* @example
* ```ts
* const regExp = new RegExp(RegExp.escape("foo.bar"));
* regExp.test("foo.bar"); // true
* regExp.test("foo!bar"); // false
* ```
*/
escape(string: string): string;
}
6 changes: 1 addition & 5 deletions src/lib/esnext.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/// <reference lib="es2024" />
/// <reference lib="es2025" />
/// <reference lib="esnext.intl" />
/// <reference lib="esnext.decorators" />
/// <reference lib="esnext.disposable" />
/// <reference lib="esnext.collection" />
/// <reference lib="esnext.array" />
/// <reference lib="esnext.iterator" />
/// <reference lib="esnext.promise" />
/// <reference lib="esnext.float16" />
/// <reference lib="esnext.error" />
/// <reference lib="esnext.sharedmemory" />
/// <reference lib="esnext.typedarrays" />
Loading
Loading