Skip to content

Commit 9d98874

Browse files
petamorikenindrajitbnikamrbuckton
authored
Introduce ES2024 target and fix some types (#58573)
Co-authored-by: indrajitbnikam <indrajitbnikam@gmail.com> Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
1 parent 52c59db commit 9d98874

File tree

148 files changed

+4315
-2804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+4315
-2804
lines changed

src/compiler/commandLineParser.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ export const inverseJsxOptionMap: Map<string, string> = new Map(mapIterator(jsxO
146146
// augmented in another lib.
147147
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
148148
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
149-
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
149+
// `ScriptTargetFeatures` transformers/esnext.ts, compiler/commandLineParser.ts and the contents of each
150+
// lib/esnext.*.d.ts file.
150151
const libEntries: [string, string][] = [
151152
// JavaScript only
152153
["es5", "lib.es5.d.ts"],
@@ -161,6 +162,7 @@ const libEntries: [string, string][] = [
161162
["es2021", "lib.es2021.d.ts"],
162163
["es2022", "lib.es2022.d.ts"],
163164
["es2023", "lib.es2023.d.ts"],
165+
["es2024", "lib.es2024.d.ts"],
164166
["esnext", "lib.esnext.d.ts"],
165167
// Host only
166168
["dom", "lib.dom.d.ts"],
@@ -183,6 +185,7 @@ const libEntries: [string, string][] = [
183185
["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"],
184186
["es2016.array.include", "lib.es2016.array.include.d.ts"],
185187
["es2016.intl", "lib.es2016.intl.d.ts"],
188+
["es2017.arraybuffer", "lib.es2017.arraybuffer.d.ts"],
186189
["es2017.date", "lib.es2017.date.d.ts"],
187190
["es2017.object", "lib.es2017.object.d.ts"],
188191
["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"],
@@ -215,12 +218,18 @@ const libEntries: [string, string][] = [
215218
["es2022.error", "lib.es2022.error.d.ts"],
216219
["es2022.intl", "lib.es2022.intl.d.ts"],
217220
["es2022.object", "lib.es2022.object.d.ts"],
218-
["es2022.sharedmemory", "lib.es2022.sharedmemory.d.ts"],
219221
["es2022.string", "lib.es2022.string.d.ts"],
220222
["es2022.regexp", "lib.es2022.regexp.d.ts"],
221223
["es2023.array", "lib.es2023.array.d.ts"],
222224
["es2023.collection", "lib.es2023.collection.d.ts"],
223225
["es2023.intl", "lib.es2023.intl.d.ts"],
226+
["es2024.arraybuffer", "lib.es2024.arraybuffer.d.ts"],
227+
["es2024.collection", "lib.es2024.collection.d.ts"],
228+
["es2024.object", "lib.es2024.object.d.ts"],
229+
["es2024.promise", "lib.es2024.promise.d.ts"],
230+
["es2024.regexp", "lib.es2024.regexp.d.ts"],
231+
["es2024.sharedmemory", "lib.es2024.sharedmemory.d.ts"],
232+
["es2024.string", "lib.es2024.string.d.ts"],
224233
["esnext.array", "lib.es2023.array.d.ts"],
225234
["esnext.collection", "lib.esnext.collection.d.ts"],
226235
["esnext.symbol", "lib.es2019.symbol.d.ts"],
@@ -229,13 +238,13 @@ const libEntries: [string, string][] = [
229238
["esnext.disposable", "lib.esnext.disposable.d.ts"],
230239
["esnext.bigint", "lib.es2020.bigint.d.ts"],
231240
["esnext.string", "lib.es2022.string.d.ts"],
232-
["esnext.promise", "lib.esnext.promise.d.ts"],
241+
["esnext.promise", "lib.es2024.promise.d.ts"],
233242
["esnext.weakref", "lib.es2021.weakref.d.ts"],
234243
["esnext.decorators", "lib.esnext.decorators.d.ts"],
235-
["esnext.object", "lib.esnext.object.d.ts"],
244+
["esnext.object", "lib.es2024.object.d.ts"],
236245
["esnext.array", "lib.esnext.array.d.ts"],
237-
["esnext.regexp", "lib.esnext.regexp.d.ts"],
238-
["esnext.string", "lib.esnext.string.d.ts"],
246+
["esnext.regexp", "lib.es2024.regexp.d.ts"],
247+
["esnext.string", "lib.es2024.string.d.ts"],
239248
["esnext.iterator", "lib.esnext.iterator.d.ts"],
240249
["decorators", "lib.decorators.d.ts"],
241250
["decorators.legacy", "lib.decorators.legacy.d.ts"],
@@ -558,6 +567,7 @@ export const targetOptionDeclaration: CommandLineOptionOfCustomType = {
558567
es2021: ScriptTarget.ES2021,
559568
es2022: ScriptTarget.ES2022,
560569
es2023: ScriptTarget.ES2023,
570+
es2024: ScriptTarget.ES2024,
561571
esnext: ScriptTarget.ESNext,
562572
})),
563573
affectsSourceFile: true,

src/compiler/transformers/esnext.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ const enum UsingKind {
7474
export function transformESNext(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
7575
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
7676
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
77-
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
77+
// `ScriptTargetFeatures` transformers/esnext.ts, compiler/commandLineParser.ts and the contents of each
78+
// lib/esnext.*.d.ts file.
7879

7980
const {
8081
factory,

src/compiler/types.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -7577,7 +7577,8 @@ export const enum ScriptKind {
75777577

75787578
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
75797579
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
7580-
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
7580+
// `ScriptTargetFeatures` transformers/esnext.ts, compiler/commandLineParser.ts and the contents of each
7581+
// lib/esnext.*.d.ts file.
75817582
export const enum ScriptTarget {
75827583
/** @deprecated */
75837584
ES3 = 0,
@@ -7591,6 +7592,7 @@ export const enum ScriptTarget {
75917592
ES2021 = 8,
75927593
ES2022 = 9,
75937594
ES2023 = 10,
7595+
ES2024 = 11,
75947596
ESNext = 99,
75957597
JSON = 100,
75967598
Latest = ESNext,
@@ -8379,13 +8381,15 @@ export type LanugageFeatures =
83798381
| "RegularExpressionFlagsHasIndices"
83808382
// ES2023 Features
83818383
| "ShebangComments"
8384+
// ES2024 Features
8385+
| "RegularExpressionFlagsUnicodeSets"
83828386
// Upcoming Features
83838387
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
83848388
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
8385-
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
8386-
| "UsingAndAwaitUsing"
8387-
| "ClassAndClassElementDecorators" // `using x = y`, `await using x = y`
8388-
| "RegularExpressionFlagsUnicodeSets" // `@dec class C {}`, `class C { @dec m() {} }`
8389+
// `ScriptTargetFeatures` transformers/esnext.ts, compiler/commandLineParser.ts and the contents of each
8390+
// lib/esnext.*.d.ts file.
8391+
| "UsingAndAwaitUsing" // `using x = y`, `await using x = y`
8392+
| "ClassAndClassElementDecorators" // `@dec class C {}`, `class C { @dec m() {} }`
83898393
;
83908394

83918395
/**
@@ -8424,10 +8428,10 @@ export const LanguageFeatureMinimumTarget: Record<LanugageFeatures, ScriptTarget
84248428
ClassFields: ScriptTarget.ES2022,
84258429
PrivateNamesAndClassStaticBlocks: ScriptTarget.ES2022,
84268430
RegularExpressionFlagsHasIndices: ScriptTarget.ES2022,
8427-
ShebangComments: ScriptTarget.ESNext,
8431+
ShebangComments: ScriptTarget.ES2023,
8432+
RegularExpressionFlagsUnicodeSets: ScriptTarget.ES2024,
84288433
UsingAndAwaitUsing: ScriptTarget.ESNext,
84298434
ClassAndClassElementDecorators: ScriptTarget.ESNext,
8430-
RegularExpressionFlagsUnicodeSets: ScriptTarget.ESNext,
84318435
};
84328436

84338437
// dprint-ignore

src/compiler/utilities.ts

+69-3
Original file line numberDiff line numberDiff line change
@@ -1367,6 +1367,10 @@ export function getInternalEmitFlags(node: Node): InternalEmitFlags {
13671367
/** @internal */
13681368
export type ScriptTargetFeatures = ReadonlyMap<string, ReadonlyMap<string, string[]>>;
13691369

1370+
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
1371+
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
1372+
// `ScriptTargetFeatures` transformers/esnext.ts, compiler/commandLineParser.ts and the contents of each
1373+
// lib/esnext.*.d.ts file.
13701374
/** @internal */
13711375
export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__ */ memoize((): ScriptTargetFeatures =>
13721376
new Map(Object.entries({
@@ -1405,11 +1409,45 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
14051409
AsyncIterator: new Map(Object.entries({
14061410
es2015: emptyArray,
14071411
})),
1412+
ArrayBuffer: new Map(Object.entries({
1413+
es2024: [
1414+
"maxByteLength",
1415+
"resizable",
1416+
"resize",
1417+
"detached",
1418+
"transfer",
1419+
"transferToFixedLength",
1420+
],
1421+
})),
14081422
Atomics: new Map(Object.entries({
1409-
es2017: emptyArray,
1423+
es2017: [
1424+
"add",
1425+
"and",
1426+
"compareExchange",
1427+
"exchange",
1428+
"isLockFree",
1429+
"load",
1430+
"or",
1431+
"store",
1432+
"sub",
1433+
"wait",
1434+
"notify",
1435+
"xor",
1436+
],
1437+
es2024: [
1438+
"waitAsync",
1439+
],
14101440
})),
14111441
SharedArrayBuffer: new Map(Object.entries({
1412-
es2017: emptyArray,
1442+
es2017: [
1443+
"byteLength",
1444+
"slice",
1445+
],
1446+
es2024: [
1447+
"growable",
1448+
"maxByteLength",
1449+
"grow",
1450+
],
14131451
})),
14141452
AsyncIterable: new Map(Object.entries({
14151453
es2018: emptyArray,
@@ -1432,6 +1470,9 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
14321470
es2018: [
14331471
"dotAll",
14341472
],
1473+
es2024: [
1474+
"unicodeSets",
1475+
],
14351476
})),
14361477
Reflect: new Map(Object.entries({
14371478
es2015: [
@@ -1478,6 +1519,9 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
14781519
es2022: [
14791520
"hasOwn",
14801521
],
1522+
es2024: [
1523+
"groupBy",
1524+
],
14811525
})),
14821526
NumberConstructor: new Map(Object.entries({
14831527
es2015: [
@@ -1517,12 +1561,26 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
15171561
"values",
15181562
],
15191563
})),
1564+
MapConstructor: new Map(Object.entries({
1565+
es2024: [
1566+
"groupBy",
1567+
],
1568+
})),
15201569
Set: new Map(Object.entries({
15211570
es2015: [
15221571
"entries",
15231572
"keys",
15241573
"values",
15251574
],
1575+
esnext: [
1576+
"union",
1577+
"intersection",
1578+
"difference",
1579+
"symmetricDifference",
1580+
"isSubsetOf",
1581+
"isSupersetOf",
1582+
"isDisjointFrom",
1583+
],
15261584
})),
15271585
PromiseConstructor: new Map(Object.entries({
15281586
es2015: [
@@ -1537,6 +1595,9 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
15371595
es2021: [
15381596
"any",
15391597
],
1598+
es2024: [
1599+
"withResolvers",
1600+
],
15401601
})),
15411602
Symbol: new Map(Object.entries({
15421603
es2015: [
@@ -1602,7 +1663,7 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
16021663
es2022: [
16031664
"at",
16041665
],
1605-
esnext: [
1666+
es2024: [
16061667
"isWellFormed",
16071668
"toWellFormed",
16081669
],
@@ -1648,6 +1709,11 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
16481709
es2020: [
16491710
"matchAll",
16501711
],
1712+
esnext: [
1713+
"metadata",
1714+
"dispose",
1715+
"asyncDispose",
1716+
],
16511717
})),
16521718
DataView: new Map(Object.entries({
16531719
es2020: [

src/lib/es2016.intl.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ declare namespace Intl {
44
* the canonical locale names. Duplicates will be omitted and elements
55
* will be validated as structurally valid language tags.
66
*
7-
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
7+
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
88
*
99
* @param locale A list of String values for which to get the canonical locale names
1010
* @returns An array containing the canonical and validated locale names.

src/lib/es2017.arraybuffer.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
interface ArrayBufferConstructor {
2+
new (): ArrayBuffer;
3+
}

src/lib/es2017.d.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/// <reference lib="es2016" />
2+
/// <reference lib="es2017.arraybuffer" />
3+
/// <reference lib="es2017.date" />
4+
/// <reference lib="es2017.intl" />
25
/// <reference lib="es2017.object" />
36
/// <reference lib="es2017.sharedmemory" />
47
/// <reference lib="es2017.string" />
5-
/// <reference lib="es2017.intl" />
68
/// <reference lib="es2017.typedarrays" />
7-
/// <reference lib="es2017.date" />

src/lib/es2017.sharedmemory.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ interface SharedArrayBuffer {
1010
/**
1111
* Returns a section of an SharedArrayBuffer.
1212
*/
13-
slice(begin: number, end?: number): SharedArrayBuffer;
13+
slice(begin?: number, end?: number): SharedArrayBuffer;
1414
readonly [Symbol.species]: SharedArrayBuffer;
1515
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
1616
}
1717

1818
interface SharedArrayBufferConstructor {
1919
readonly prototype: SharedArrayBuffer;
20-
new (byteLength: number): SharedArrayBuffer;
20+
new (byteLength?: number): SharedArrayBuffer;
2121
}
2222
declare var SharedArrayBuffer: SharedArrayBufferConstructor;
2323

src/lib/es2020.bigint.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
interface BigIntToLocaleStringOptions {
44
/**
5-
* The locale matching algorithm to use.The default is "best fit". For information about this option, see the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation Intl page}.
5+
* The locale matching algorithm to use.The default is "best fit". For information about this option, see the {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation Intl page}.
66
*/
77
localeMatcher?: string;
88
/**

0 commit comments

Comments
 (0)