Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ES2024 target and fix some types #58573

Merged
merged 47 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
541081d
fix(dts): add missing types to support resizable arraybuffer
indrajitbnikam Jun 13, 2023
e675236
fix(dts): add separate file to add missing arrayBuffer and sharedArra…
indrajitbnikam Jun 14, 2023
51cbc24
fix: update the baselines
indrajitbnikam Jun 17, 2023
7cb5130
Merge branch 'main' into feat/update-types
petamoriken May 19, 2024
0d5841a
Update JSDoc
petamoriken May 19, 2024
2b68ab7
Update: migrate to ES2024
petamoriken May 19, 2024
2161140
Fix ES2017 types
petamoriken May 19, 2024
965a2cb
Update: add ES2024 ArrayBuffer transfer
petamoriken May 19, 2024
c7afa96
Fix ES2024 types
petamoriken May 19, 2024
67d6277
Update src/lib/libs.json
petamoriken May 19, 2024
ae9f93f
Add test cases
petamoriken May 19, 2024
c2e6381
Tweak
petamoriken May 19, 2024
4a3a8fc
Update baselines
petamoriken May 19, 2024
dc52cdf
Fix the mistake
petamoriken May 19, 2024
378fdb9
Update baselines
petamoriken May 19, 2024
bfc5b41
Fix `ArrayBuffer.prototype.slice` type
petamoriken May 19, 2024
eb7a391
Tweak
petamoriken May 19, 2024
8e19150
Tweak
petamoriken May 19, 2024
0d60852
Introduce ES2024 target
petamoriken May 19, 2024
5a38111
Update baselines
petamoriken May 19, 2024
e306c6a
Tweak MDN URLs
petamoriken May 19, 2024
689e5ee
Merge branch 'main' into feat/update-types
petamoriken May 24, 2024
3dd8b73
Merge branch 'main' into feat/update-types
petamoriken May 26, 2024
6b5d953
Fix: move `Atomics.waitAsync` types to ES2024
petamoriken May 26, 2024
99c1684
Update baselines
petamoriken May 26, 2024
ffa4c9b
Tweak
petamoriken May 26, 2024
5b0e12a
Fix
petamoriken May 26, 2024
1f67edc
Update baselines
petamoriken May 27, 2024
fbd2e18
Merge branch 'main' into feat/update-types
petamoriken Jun 13, 2024
5dd9ddb
Merge branch 'main' into feat/update-types
petamoriken Jul 6, 2024
c41d45c
update suggestions
petamoriken Jul 6, 2024
f0e156a
Update NOTE comments
petamoriken Jul 7, 2024
1b26a55
Merge branch 'main' into feat/update-types
petamoriken Jul 20, 2024
2e0a288
Update src/lib/es2024.collection.d.ts
petamoriken Jul 23, 2024
59ce25d
Merge branch 'main' into feat/update-types
petamoriken Jul 23, 2024
25ede1f
tweak
petamoriken Jul 23, 2024
f354580
add ES2024 Atomics.wait test for ES2022 lib
petamoriken Jul 23, 2024
dee70c4
update baselines
petamoriken Jul 23, 2024
604956a
update es2024SharedMemory.ts
petamoriken Jul 24, 2024
eeffd20
update baselines
petamoriken Jul 24, 2024
c5efb87
fix
petamoriken Aug 1, 2024
5e73d09
Merge branch 'main' into feat/update-types
petamoriken Aug 1, 2024
d40ae6d
Merge branch 'main' into feat/update-types
petamoriken Aug 10, 2024
1b35d86
Fix `Iterable`
petamoriken Aug 11, 2024
aa80f7c
Merge branch 'main' into feat/update-types
petamoriken Sep 10, 2024
58d0298
Merge branch 'main' into feat/update-types
petamoriken Sep 24, 2024
d336661
update comments
petamoriken Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ export const inverseJsxOptionMap: Map<string, string> = new Map(mapIterator(jsxO
// augmented in another lib.
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
// `ScriptTargetFeatures` transformers/esnext.ts, compiler/commandLineParser.ts and the contents of each
// lib/esnext.*.d.ts file.
const libEntries: [string, string][] = [
// JavaScript only
["es5", "lib.es5.d.ts"],
Expand All @@ -161,6 +162,7 @@ const libEntries: [string, string][] = [
["es2021", "lib.es2021.d.ts"],
["es2022", "lib.es2022.d.ts"],
["es2023", "lib.es2023.d.ts"],
["es2024", "lib.es2024.d.ts"],
["esnext", "lib.esnext.d.ts"],
// Host only
["dom", "lib.dom.d.ts"],
Expand All @@ -183,6 +185,7 @@ const libEntries: [string, string][] = [
["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"],
["es2016.array.include", "lib.es2016.array.include.d.ts"],
["es2016.intl", "lib.es2016.intl.d.ts"],
["es2017.arraybuffer", "lib.es2017.arraybuffer.d.ts"],
["es2017.date", "lib.es2017.date.d.ts"],
["es2017.object", "lib.es2017.object.d.ts"],
["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"],
Expand Down Expand Up @@ -215,12 +218,18 @@ const libEntries: [string, string][] = [
["es2022.error", "lib.es2022.error.d.ts"],
["es2022.intl", "lib.es2022.intl.d.ts"],
["es2022.object", "lib.es2022.object.d.ts"],
["es2022.sharedmemory", "lib.es2022.sharedmemory.d.ts"],
petamoriken marked this conversation as resolved.
Show resolved Hide resolved
["es2022.string", "lib.es2022.string.d.ts"],
["es2022.regexp", "lib.es2022.regexp.d.ts"],
["es2023.array", "lib.es2023.array.d.ts"],
["es2023.collection", "lib.es2023.collection.d.ts"],
["es2023.intl", "lib.es2023.intl.d.ts"],
["es2024.arraybuffer", "lib.es2024.arraybuffer.d.ts"],
["es2024.collection", "lib.es2024.collection.d.ts"],
["es2024.object", "lib.es2024.object.d.ts"],
["es2024.promise", "lib.es2024.promise.d.ts"],
["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"],
Expand All @@ -229,13 +238,13 @@ const libEntries: [string, string][] = [
["esnext.disposable", "lib.esnext.disposable.d.ts"],
["esnext.bigint", "lib.es2020.bigint.d.ts"],
["esnext.string", "lib.es2022.string.d.ts"],
["esnext.promise", "lib.esnext.promise.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.esnext.object.d.ts"],
["esnext.object", "lib.es2024.object.d.ts"],
["esnext.array", "lib.esnext.array.d.ts"],
["esnext.regexp", "lib.esnext.regexp.d.ts"],
["esnext.string", "lib.esnext.string.d.ts"],
["esnext.regexp", "lib.es2024.regexp.d.ts"],
["esnext.string", "lib.es2024.string.d.ts"],
["esnext.iterator", "lib.esnext.iterator.d.ts"],
["decorators", "lib.decorators.d.ts"],
["decorators.legacy", "lib.decorators.legacy.d.ts"],
Expand Down Expand Up @@ -558,6 +567,7 @@ export const targetOptionDeclaration: CommandLineOptionOfCustomType = {
es2021: ScriptTarget.ES2021,
es2022: ScriptTarget.ES2022,
es2023: ScriptTarget.ES2023,
es2024: ScriptTarget.ES2024,
esnext: ScriptTarget.ESNext,
})),
affectsSourceFile: true,
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/transformers/esnext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ const enum UsingKind {
export function transformESNext(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
// `ScriptTargetFeatures` transformers/esnext.ts, compiler/commandLineParser.ts and the contents of each
// lib/esnext.*.d.ts file.

const {
factory,
Expand Down
18 changes: 11 additions & 7 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7577,7 +7577,8 @@ export const enum ScriptKind {

// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
// `ScriptTargetFeatures` transformers/esnext.ts, compiler/commandLineParser.ts and the contents of each
// lib/esnext.*.d.ts file.
export const enum ScriptTarget {
/** @deprecated */
ES3 = 0,
Expand All @@ -7591,6 +7592,7 @@ export const enum ScriptTarget {
ES2021 = 8,
ES2022 = 9,
ES2023 = 10,
ES2024 = 11,
ESNext = 99,
JSON = 100,
Latest = ESNext,
Expand Down Expand Up @@ -8379,13 +8381,15 @@ export type LanugageFeatures =
| "RegularExpressionFlagsHasIndices"
// ES2023 Features
| "ShebangComments"
// ES2024 Features
| "RegularExpressionFlagsUnicodeSets"
// Upcoming Features
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
| "UsingAndAwaitUsing"
| "ClassAndClassElementDecorators" // `using x = y`, `await using x = y`
| "RegularExpressionFlagsUnicodeSets" // `@dec class C {}`, `class C { @dec m() {} }`
// `ScriptTargetFeatures` transformers/esnext.ts, compiler/commandLineParser.ts and the contents of each
// lib/esnext.*.d.ts file.
| "UsingAndAwaitUsing" // `using x = y`, `await using x = y`
| "ClassAndClassElementDecorators" // `@dec class C {}`, `class C { @dec m() {} }`
;

/**
Expand Down Expand Up @@ -8424,10 +8428,10 @@ export const LanguageFeatureMinimumTarget: Record<LanugageFeatures, ScriptTarget
ClassFields: ScriptTarget.ES2022,
PrivateNamesAndClassStaticBlocks: ScriptTarget.ES2022,
RegularExpressionFlagsHasIndices: ScriptTarget.ES2022,
ShebangComments: ScriptTarget.ESNext,
ShebangComments: ScriptTarget.ES2023,
RegularExpressionFlagsUnicodeSets: ScriptTarget.ES2024,
UsingAndAwaitUsing: ScriptTarget.ESNext,
ClassAndClassElementDecorators: ScriptTarget.ESNext,
RegularExpressionFlagsUnicodeSets: ScriptTarget.ESNext,
};

// dprint-ignore
Expand Down
72 changes: 69 additions & 3 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,10 @@ export function getInternalEmitFlags(node: Node): InternalEmitFlags {
/** @internal */
export type ScriptTargetFeatures = ReadonlyMap<string, ReadonlyMap<string, string[]>>;

// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
// `ScriptTargetFeatures` transformers/esnext.ts, compiler/commandLineParser.ts and the contents of each
// lib/esnext.*.d.ts file.
/** @internal */
export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__ */ memoize((): ScriptTargetFeatures =>
new Map(Object.entries({
Expand Down Expand Up @@ -1405,11 +1409,45 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
AsyncIterator: new Map(Object.entries({
es2015: emptyArray,
})),
ArrayBuffer: new Map(Object.entries({
es2024: [
"maxByteLength",
"resizable",
"resize",
"detached",
"transfer",
"transferToFixedLength",
],
})),
Atomics: new Map(Object.entries({
es2017: emptyArray,
es2017: [
"add",
"and",
"compareExchange",
"exchange",
"isLockFree",
"load",
"or",
"store",
"sub",
"wait",
"notify",
"xor",
],
es2024: [
"waitAsync",
],
})),
SharedArrayBuffer: new Map(Object.entries({
es2017: emptyArray,
es2017: [
"byteLength",
"slice",
],
es2024: [
"growable",
"maxByteLength",
"grow",
],
})),
AsyncIterable: new Map(Object.entries({
es2018: emptyArray,
Expand All @@ -1432,6 +1470,9 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
es2018: [
"dotAll",
],
es2024: [
"unicodeSets",
],
})),
Reflect: new Map(Object.entries({
es2015: [
Expand Down Expand Up @@ -1478,6 +1519,9 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
es2022: [
"hasOwn",
],
es2024: [
"groupBy",
],
})),
NumberConstructor: new Map(Object.entries({
es2015: [
Expand Down Expand Up @@ -1517,12 +1561,26 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
"values",
],
})),
MapConstructor: new Map(Object.entries({
es2024: [
"groupBy",
],
})),
Set: new Map(Object.entries({
es2015: [
"entries",
"keys",
"values",
],
esnext: [
"union",
"intersection",
"difference",
"symmetricDifference",
"isSubsetOf",
"isSupersetOf",
"isDisjointFrom",
],
})),
PromiseConstructor: new Map(Object.entries({
es2015: [
Expand All @@ -1537,6 +1595,9 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
es2021: [
"any",
],
es2024: [
"withResolvers",
],
})),
Symbol: new Map(Object.entries({
es2015: [
Expand Down Expand Up @@ -1602,7 +1663,7 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
es2022: [
"at",
],
esnext: [
es2024: [
"isWellFormed",
"toWellFormed",
],
Expand Down Expand Up @@ -1648,6 +1709,11 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
es2020: [
"matchAll",
],
esnext: [
"metadata",
"dispose",
"asyncDispose",
],
})),
DataView: new Map(Object.entries({
es2020: [
Expand Down
2 changes: 1 addition & 1 deletion src/lib/es2016.intl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ declare namespace Intl {
* the canonical locale names. Duplicates will be omitted and elements
* will be validated as structurally valid language tags.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
*
* @param locale A list of String values for which to get the canonical locale names
* @returns An array containing the canonical and validated locale names.
Expand Down
3 changes: 3 additions & 0 deletions src/lib/es2017.arraybuffer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface ArrayBufferConstructor {
new (): ArrayBuffer;
}
5 changes: 3 additions & 2 deletions src/lib/es2017.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/// <reference lib="es2016" />
/// <reference lib="es2017.arraybuffer" />
/// <reference lib="es2017.date" />
/// <reference lib="es2017.intl" />
/// <reference lib="es2017.object" />
/// <reference lib="es2017.sharedmemory" />
/// <reference lib="es2017.string" />
/// <reference lib="es2017.intl" />
/// <reference lib="es2017.typedarrays" />
/// <reference lib="es2017.date" />
4 changes: 2 additions & 2 deletions src/lib/es2017.sharedmemory.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ interface SharedArrayBuffer {
/**
* Returns a section of an SharedArrayBuffer.
*/
slice(begin: number, end?: number): SharedArrayBuffer;
slice(begin?: number, end?: number): SharedArrayBuffer;
readonly [Symbol.species]: SharedArrayBuffer;
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
}

interface SharedArrayBufferConstructor {
readonly prototype: SharedArrayBuffer;
new (byteLength: number): SharedArrayBuffer;
new (byteLength?: number): SharedArrayBuffer;
}
declare var SharedArrayBuffer: SharedArrayBufferConstructor;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/es2020.bigint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

interface BigIntToLocaleStringOptions {
/**
* 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}.
* 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}.
*/
localeMatcher?: string;
/**
Expand Down
Loading