Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ const libEntries: [string, string][] = [
["esnext.object", "lib.es2024.object.d.ts"],
["esnext.regexp", "lib.es2024.regexp.d.ts"],
["esnext.string", "lib.es2024.string.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.collection", "lib.esnext.collection.d.ts"],
["esnext.decorators", "lib.esnext.decorators.d.ts"],
["esnext.disposable", "lib.esnext.disposable.d.ts"],
["esnext.error", "lib.esnext.error.d.ts"],
Expand Down
8 changes: 8 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,10 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
"keys",
"values",
],
esnext: [
"getOrInsert",
"getOrInsertComputed",
],
})),
MapConstructor: new Map(Object.entries({
es2024: [
Expand Down Expand Up @@ -1637,6 +1641,10 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__
"keys",
"values",
],
esnext: [
"getOrInsert",
"getOrInsertComputed",
],
})),
WeakSet: new Map(Object.entries({
es2015: [
Expand Down
31 changes: 31 additions & 0 deletions src/lib/esnext.collection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/// <reference lib="es2025.collection" />

interface Map<K, V> {
/**
* Returns a specified element from the Map object.
* If no element is associated with the specified key, a new element with the value `defaultValue` will be inserted into the Map and returned.
* @returns The element associated with the specified key, which will be `defaultValue` if no element previously existed.
*/
getOrInsert(key: K, defaultValue: V): V;
/**
* Returns a specified element from the Map object.
* If no element is associated with the specified key, the result of passing the specified key to the `callback` function will be inserted into the Map and returned.
* @returns The element associated with the specific key, which will be the newly computed value if no element previously existed.
*/
getOrInsertComputed(key: K, callback: (key: K) => V): V;
}

interface WeakMap<K extends WeakKey, V> {
/**
* Returns a specified element from the WeakMap object.
* If no element is associated with the specified key, a new element with the value `defaultValue` will be inserted into the WeakMap and returned.
* @returns The element associated with the specified key, which will be `defaultValue` if no element previously existed.
*/
getOrInsert(key: K, defaultValue: V): V;
/**
* Returns a specified element from the WeakMap object.
* If no element is associated with the specified key, the result of passing the specified key to the `callback` function will be inserted into the WeakMap and returned.
* @returns The element associated with the specific key, which will be the newly computed value if no element previously existed.
*/
getOrInsertComputed(key: K, callback: (key: K) => V): V;
}
1 change: 1 addition & 0 deletions src/lib/esnext.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference lib="es2025" />
/// <reference lib="esnext.intl" />
/// <reference lib="esnext.collection" />
/// <reference lib="esnext.decorators" />
/// <reference lib="esnext.disposable" />
/// <reference lib="esnext.array" />
Expand Down
1 change: 1 addition & 0 deletions src/lib/libs.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"es2025.promise",
"es2025.regexp",
"esnext.array",
"esnext.collection",
"esnext.decorators",
"esnext.disposable",
"esnext.error",
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/acceptSymbolAsWeakType.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ws.delete(s);

const wm = new WeakMap([[s, false]]);
>wm : Symbol(wm, Decl(acceptSymbolAsWeakType.ts, 7, 5))
>WeakMap : Symbol(WeakMap, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>WeakMap : Symbol(WeakMap, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.collection.d.ts, --, --))
>s : Symbol(s, Decl(acceptSymbolAsWeakType.ts, 0, 5))

wm.set(s, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function f() {
await using it5 = new Map<string, string>().entries();
>it5 : Symbol(it5, Decl(awaitUsingDeclarationsWithIteratorObject.ts, 15, 15))
>new Map<string, string>().entries : Symbol(Map.entries, Decl(lib.es2015.iterable.d.ts, --, --))
>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.collection.d.ts, --, --))
>entries : Symbol(Map.entries, Decl(lib.es2015.iterable.d.ts, --, --))

await using it6 = new Set<string>().keys();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ declare const array: number[];

declare const map: Map<string, number>;
>map : Symbol(map, Decl(builtinIteratorReturn.ts, 1, 13))
>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.collection.d.ts, --, --))

declare const set: Set<number>;
>set : Symbol(set, Decl(builtinIteratorReturn.ts, 2, 13))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ declare const array: number[];

declare const map: Map<string, number>;
>map : Symbol(map, Decl(builtinIteratorReturn.ts, 1, 13))
>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.collection.d.ts, --, --))

declare const set: Set<number>;
>set : Symbol(set, Decl(builtinIteratorReturn.ts, 2, 13))
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading