From b1ea83a46c9ab68b3a3ac2680a65ef47e7e5aabf Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 29 Jan 2024 22:30:08 -0800 Subject: [PATCH 1/8] add types for set methods proposal --- src/lib/esnext.collection.d.ts | 46 +++ .../baselines/reference/setMethods.errors.txt | 111 +++++++ tests/baselines/reference/setMethods.js | 102 ++++++ tests/baselines/reference/setMethods.symbols | 234 ++++++++++++++ tests/baselines/reference/setMethods.types | 306 ++++++++++++++++++ tests/cases/compiler/setMethods.ts | 55 ++++ 6 files changed, 854 insertions(+) create mode 100644 tests/baselines/reference/setMethods.errors.txt create mode 100644 tests/baselines/reference/setMethods.js create mode 100644 tests/baselines/reference/setMethods.symbols create mode 100644 tests/baselines/reference/setMethods.types create mode 100644 tests/cases/compiler/setMethods.ts diff --git a/src/lib/esnext.collection.d.ts b/src/lib/esnext.collection.d.ts index 7a799f3c494e7..95be718e43837 100644 --- a/src/lib/esnext.collection.d.ts +++ b/src/lib/esnext.collection.d.ts @@ -9,3 +9,49 @@ interface MapConstructor { keySelector: (item: T, index: number) => K, ): Map; } + +interface SetLike { + /** + * Despite its name, returns an iterable of the values in the set-like. + */ + keys(): Iterable; + /** + * @returns a boolean indicating whether an element with the specified value exists in the set-like or not. + */ + has(value: T): boolean; + /** + * @returns the number of (unique) elements in the set-like. + */ + readonly size: number; +} + +interface Set { + /** + * @returns a new Set containing all the elements in this Set and also all the elements in the argument. + */ + union(other: SetLike): Set; + /** + * @returns a new Set containing all the elements which are both in this Set and in the argument. + */ + intersection(other: SetLike): Set; + /** + * @returns a new Set containing all the elements in this Set which are not also in the argument. + */ + difference(other: SetLike): Set; + /** + * @returns a new Set containing all the elements in this Set which are in this or in the argument, but not in both. + */ + symmetricDifference(other: SetLike): Set; + /** + * @returns a boolean indicating whether all the elements in this Set are also in the argument. + */ + isSubsetOf(other: SetLike): Set; + /** + * @returns a boolean indicating whether all the elements in the argument are also in this Set. + */ + isSupersetOf(other: SetLike): Set; + /** + * @returns a boolean indicating whether this Set has no elements in common with the argument. + */ + isDisjointFrom(other: SetLike): Set; +} diff --git a/tests/baselines/reference/setMethods.errors.txt b/tests/baselines/reference/setMethods.errors.txt new file mode 100644 index 0000000000000..4d6b227d46ebe --- /dev/null +++ b/tests/baselines/reference/setMethods.errors.txt @@ -0,0 +1,111 @@ +setMethods.ts(13,17): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. + Type 'undefined[]' is missing the following properties from type 'SetLike': has, size +setMethods.ts(15,17): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. + The types returned by 'keys()[Symbol.iterator]().next(...)' are incompatible between these types. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. + Type 'string' is not assignable to type 'number'. +setMethods.ts(19,24): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +setMethods.ts(21,24): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. +setMethods.ts(25,22): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +setMethods.ts(27,22): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. +setMethods.ts(31,31): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +setMethods.ts(33,31): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. +setMethods.ts(37,22): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +setMethods.ts(39,22): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. +setMethods.ts(43,24): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +setMethods.ts(45,24): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. +setMethods.ts(49,26): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +setMethods.ts(51,26): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. + + +==== setMethods.ts (14 errors) ==== + let numberSet = new Set([0, 1, 2]); + + let stringSet = new Set(["a", "b"]); + + let numberMap = new Map([[4, {}], [5, {}]]); + + let numberSetLike = { + size: 1, + *keys() { yield 3 }, + has(x) { return x === 3 }, + }; + + numberSet.union([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +!!! error TS2345: Type 'undefined[]' is missing the following properties from type 'SetLike': has, size + numberSet.union(new Set); + numberSet.union(stringSet); + ~~~~~~~~~ +!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. +!!! error TS2345: The types returned by 'keys()[Symbol.iterator]().next(...)' are incompatible between these types. +!!! error TS2345: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. +!!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + numberSet.union(numberMap); + numberSet.union(numberSetLike); + + numberSet.intersection([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. + numberSet.intersection(new Set); + numberSet.intersection(stringSet); + ~~~~~~~~~ +!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. + numberSet.intersection(numberMap); + numberSet.intersection(numberSetLike); + + numberSet.difference([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. + numberSet.difference(new Set); + numberSet.difference(stringSet); + ~~~~~~~~~ +!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. + numberSet.difference(numberMap); + numberSet.difference(numberSetLike); + + numberSet.symmetricDifference([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. + numberSet.symmetricDifference(new Set); + numberSet.symmetricDifference(stringSet); + ~~~~~~~~~ +!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. + numberSet.symmetricDifference(numberMap); + numberSet.symmetricDifference(numberSetLike); + + numberSet.isSubsetOf([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. + numberSet.isSubsetOf(new Set); + numberSet.isSubsetOf(stringSet); + ~~~~~~~~~ +!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. + numberSet.isSubsetOf(numberMap); + numberSet.isSubsetOf(numberSetLike); + + numberSet.isSupersetOf([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. + numberSet.isSupersetOf(new Set); + numberSet.isSupersetOf(stringSet); + ~~~~~~~~~ +!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. + numberSet.isSupersetOf(numberMap); + numberSet.isSupersetOf(numberSetLike); + + numberSet.isDisjointFrom([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. + numberSet.isDisjointFrom(new Set); + numberSet.isDisjointFrom(stringSet); + ~~~~~~~~~ +!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. + numberSet.isDisjointFrom(numberMap); + numberSet.isDisjointFrom(numberSetLike); + \ No newline at end of file diff --git a/tests/baselines/reference/setMethods.js b/tests/baselines/reference/setMethods.js new file mode 100644 index 0000000000000..b8c41f96afba7 --- /dev/null +++ b/tests/baselines/reference/setMethods.js @@ -0,0 +1,102 @@ +//// [tests/cases/compiler/setMethods.ts] //// + +//// [setMethods.ts] +let numberSet = new Set([0, 1, 2]); + +let stringSet = new Set(["a", "b"]); + +let numberMap = new Map([[4, {}], [5, {}]]); + +let numberSetLike = { + size: 1, + *keys() { yield 3 }, + has(x) { return x === 3 }, +}; + +numberSet.union([]); +numberSet.union(new Set); +numberSet.union(stringSet); +numberSet.union(numberMap); +numberSet.union(numberSetLike); + +numberSet.intersection([]); +numberSet.intersection(new Set); +numberSet.intersection(stringSet); +numberSet.intersection(numberMap); +numberSet.intersection(numberSetLike); + +numberSet.difference([]); +numberSet.difference(new Set); +numberSet.difference(stringSet); +numberSet.difference(numberMap); +numberSet.difference(numberSetLike); + +numberSet.symmetricDifference([]); +numberSet.symmetricDifference(new Set); +numberSet.symmetricDifference(stringSet); +numberSet.symmetricDifference(numberMap); +numberSet.symmetricDifference(numberSetLike); + +numberSet.isSubsetOf([]); +numberSet.isSubsetOf(new Set); +numberSet.isSubsetOf(stringSet); +numberSet.isSubsetOf(numberMap); +numberSet.isSubsetOf(numberSetLike); + +numberSet.isSupersetOf([]); +numberSet.isSupersetOf(new Set); +numberSet.isSupersetOf(stringSet); +numberSet.isSupersetOf(numberMap); +numberSet.isSupersetOf(numberSetLike); + +numberSet.isDisjointFrom([]); +numberSet.isDisjointFrom(new Set); +numberSet.isDisjointFrom(stringSet); +numberSet.isDisjointFrom(numberMap); +numberSet.isDisjointFrom(numberSetLike); + + +//// [setMethods.js] +let numberSet = new Set([0, 1, 2]); +let stringSet = new Set(["a", "b"]); +let numberMap = new Map([[4, {}], [5, {}]]); +let numberSetLike = { + size: 1, + *keys() { yield 3; }, + has(x) { return x === 3; }, +}; +numberSet.union([]); +numberSet.union(new Set); +numberSet.union(stringSet); +numberSet.union(numberMap); +numberSet.union(numberSetLike); +numberSet.intersection([]); +numberSet.intersection(new Set); +numberSet.intersection(stringSet); +numberSet.intersection(numberMap); +numberSet.intersection(numberSetLike); +numberSet.difference([]); +numberSet.difference(new Set); +numberSet.difference(stringSet); +numberSet.difference(numberMap); +numberSet.difference(numberSetLike); +numberSet.symmetricDifference([]); +numberSet.symmetricDifference(new Set); +numberSet.symmetricDifference(stringSet); +numberSet.symmetricDifference(numberMap); +numberSet.symmetricDifference(numberSetLike); +numberSet.isSubsetOf([]); +numberSet.isSubsetOf(new Set); +numberSet.isSubsetOf(stringSet); +numberSet.isSubsetOf(numberMap); +numberSet.isSubsetOf(numberSetLike); +numberSet.isSupersetOf([]); +numberSet.isSupersetOf(new Set); +numberSet.isSupersetOf(stringSet); +numberSet.isSupersetOf(numberMap); +numberSet.isSupersetOf(numberSetLike); +numberSet.isDisjointFrom([]); +numberSet.isDisjointFrom(new Set); +numberSet.isDisjointFrom(stringSet); +numberSet.isDisjointFrom(numberMap); +numberSet.isDisjointFrom(numberSetLike); diff --git a/tests/baselines/reference/setMethods.symbols b/tests/baselines/reference/setMethods.symbols new file mode 100644 index 0000000000000..e2c233be0d99e --- /dev/null +++ b/tests/baselines/reference/setMethods.symbols @@ -0,0 +1,234 @@ +//// [tests/cases/compiler/setMethods.ts] //// + +=== setMethods.ts === +let numberSet = new Set([0, 1, 2]); +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>Set : Symbol(Set, 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, --, --)) + +let stringSet = new Set(["a", "b"]); +>stringSet : Symbol(stringSet, Decl(setMethods.ts, 2, 3)) +>Set : Symbol(Set, 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, --, --)) + +let numberMap = new Map([[4, {}], [5, {}]]); +>numberMap : Symbol(numberMap, Decl(setMethods.ts, 4, 3)) +>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, --, --)) + +let numberSetLike = { +>numberSetLike : Symbol(numberSetLike, Decl(setMethods.ts, 6, 3)) + + size: 1, +>size : Symbol(size, Decl(setMethods.ts, 6, 21)) + + *keys() { yield 3 }, +>keys : Symbol(keys, Decl(setMethods.ts, 7, 10)) + + has(x) { return x === 3 }, +>has : Symbol(has, Decl(setMethods.ts, 8, 22)) +>x : Symbol(x, Decl(setMethods.ts, 9, 6)) +>x : Symbol(x, Decl(setMethods.ts, 9, 6)) + +}; + +numberSet.union([]); +>numberSet.union : Symbol(Set.union, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>union : Symbol(Set.union, Decl(lib.esnext.collection.d.ts, --, --)) + +numberSet.union(new Set); +>numberSet.union : Symbol(Set.union, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>union : Symbol(Set.union, Decl(lib.esnext.collection.d.ts, --, --)) +>Set : Symbol(Set, 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, --, --)) + +numberSet.union(stringSet); +>numberSet.union : Symbol(Set.union, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>union : Symbol(Set.union, Decl(lib.esnext.collection.d.ts, --, --)) +>stringSet : Symbol(stringSet, Decl(setMethods.ts, 2, 3)) + +numberSet.union(numberMap); +>numberSet.union : Symbol(Set.union, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>union : Symbol(Set.union, Decl(lib.esnext.collection.d.ts, --, --)) +>numberMap : Symbol(numberMap, Decl(setMethods.ts, 4, 3)) + +numberSet.union(numberSetLike); +>numberSet.union : Symbol(Set.union, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>union : Symbol(Set.union, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSetLike : Symbol(numberSetLike, Decl(setMethods.ts, 6, 3)) + +numberSet.intersection([]); +>numberSet.intersection : Symbol(Set.intersection, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>intersection : Symbol(Set.intersection, Decl(lib.esnext.collection.d.ts, --, --)) + +numberSet.intersection(new Set); +>numberSet.intersection : Symbol(Set.intersection, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>intersection : Symbol(Set.intersection, Decl(lib.esnext.collection.d.ts, --, --)) +>Set : Symbol(Set, 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, --, --)) + +numberSet.intersection(stringSet); +>numberSet.intersection : Symbol(Set.intersection, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>intersection : Symbol(Set.intersection, Decl(lib.esnext.collection.d.ts, --, --)) +>stringSet : Symbol(stringSet, Decl(setMethods.ts, 2, 3)) + +numberSet.intersection(numberMap); +>numberSet.intersection : Symbol(Set.intersection, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>intersection : Symbol(Set.intersection, Decl(lib.esnext.collection.d.ts, --, --)) +>numberMap : Symbol(numberMap, Decl(setMethods.ts, 4, 3)) + +numberSet.intersection(numberSetLike); +>numberSet.intersection : Symbol(Set.intersection, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>intersection : Symbol(Set.intersection, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSetLike : Symbol(numberSetLike, Decl(setMethods.ts, 6, 3)) + +numberSet.difference([]); +>numberSet.difference : Symbol(Set.difference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>difference : Symbol(Set.difference, Decl(lib.esnext.collection.d.ts, --, --)) + +numberSet.difference(new Set); +>numberSet.difference : Symbol(Set.difference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>difference : Symbol(Set.difference, Decl(lib.esnext.collection.d.ts, --, --)) +>Set : Symbol(Set, 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, --, --)) + +numberSet.difference(stringSet); +>numberSet.difference : Symbol(Set.difference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>difference : Symbol(Set.difference, Decl(lib.esnext.collection.d.ts, --, --)) +>stringSet : Symbol(stringSet, Decl(setMethods.ts, 2, 3)) + +numberSet.difference(numberMap); +>numberSet.difference : Symbol(Set.difference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>difference : Symbol(Set.difference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberMap : Symbol(numberMap, Decl(setMethods.ts, 4, 3)) + +numberSet.difference(numberSetLike); +>numberSet.difference : Symbol(Set.difference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>difference : Symbol(Set.difference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSetLike : Symbol(numberSetLike, Decl(setMethods.ts, 6, 3)) + +numberSet.symmetricDifference([]); +>numberSet.symmetricDifference : Symbol(Set.symmetricDifference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>symmetricDifference : Symbol(Set.symmetricDifference, Decl(lib.esnext.collection.d.ts, --, --)) + +numberSet.symmetricDifference(new Set); +>numberSet.symmetricDifference : Symbol(Set.symmetricDifference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>symmetricDifference : Symbol(Set.symmetricDifference, Decl(lib.esnext.collection.d.ts, --, --)) +>Set : Symbol(Set, 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, --, --)) + +numberSet.symmetricDifference(stringSet); +>numberSet.symmetricDifference : Symbol(Set.symmetricDifference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>symmetricDifference : Symbol(Set.symmetricDifference, Decl(lib.esnext.collection.d.ts, --, --)) +>stringSet : Symbol(stringSet, Decl(setMethods.ts, 2, 3)) + +numberSet.symmetricDifference(numberMap); +>numberSet.symmetricDifference : Symbol(Set.symmetricDifference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>symmetricDifference : Symbol(Set.symmetricDifference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberMap : Symbol(numberMap, Decl(setMethods.ts, 4, 3)) + +numberSet.symmetricDifference(numberSetLike); +>numberSet.symmetricDifference : Symbol(Set.symmetricDifference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>symmetricDifference : Symbol(Set.symmetricDifference, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSetLike : Symbol(numberSetLike, Decl(setMethods.ts, 6, 3)) + +numberSet.isSubsetOf([]); +>numberSet.isSubsetOf : Symbol(Set.isSubsetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isSubsetOf : Symbol(Set.isSubsetOf, Decl(lib.esnext.collection.d.ts, --, --)) + +numberSet.isSubsetOf(new Set); +>numberSet.isSubsetOf : Symbol(Set.isSubsetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isSubsetOf : Symbol(Set.isSubsetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>Set : Symbol(Set, 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, --, --)) + +numberSet.isSubsetOf(stringSet); +>numberSet.isSubsetOf : Symbol(Set.isSubsetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isSubsetOf : Symbol(Set.isSubsetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>stringSet : Symbol(stringSet, Decl(setMethods.ts, 2, 3)) + +numberSet.isSubsetOf(numberMap); +>numberSet.isSubsetOf : Symbol(Set.isSubsetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isSubsetOf : Symbol(Set.isSubsetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberMap : Symbol(numberMap, Decl(setMethods.ts, 4, 3)) + +numberSet.isSubsetOf(numberSetLike); +>numberSet.isSubsetOf : Symbol(Set.isSubsetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isSubsetOf : Symbol(Set.isSubsetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSetLike : Symbol(numberSetLike, Decl(setMethods.ts, 6, 3)) + +numberSet.isSupersetOf([]); +>numberSet.isSupersetOf : Symbol(Set.isSupersetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isSupersetOf : Symbol(Set.isSupersetOf, Decl(lib.esnext.collection.d.ts, --, --)) + +numberSet.isSupersetOf(new Set); +>numberSet.isSupersetOf : Symbol(Set.isSupersetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isSupersetOf : Symbol(Set.isSupersetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>Set : Symbol(Set, 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, --, --)) + +numberSet.isSupersetOf(stringSet); +>numberSet.isSupersetOf : Symbol(Set.isSupersetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isSupersetOf : Symbol(Set.isSupersetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>stringSet : Symbol(stringSet, Decl(setMethods.ts, 2, 3)) + +numberSet.isSupersetOf(numberMap); +>numberSet.isSupersetOf : Symbol(Set.isSupersetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isSupersetOf : Symbol(Set.isSupersetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberMap : Symbol(numberMap, Decl(setMethods.ts, 4, 3)) + +numberSet.isSupersetOf(numberSetLike); +>numberSet.isSupersetOf : Symbol(Set.isSupersetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isSupersetOf : Symbol(Set.isSupersetOf, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSetLike : Symbol(numberSetLike, Decl(setMethods.ts, 6, 3)) + +numberSet.isDisjointFrom([]); +>numberSet.isDisjointFrom : Symbol(Set.isDisjointFrom, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isDisjointFrom : Symbol(Set.isDisjointFrom, Decl(lib.esnext.collection.d.ts, --, --)) + +numberSet.isDisjointFrom(new Set); +>numberSet.isDisjointFrom : Symbol(Set.isDisjointFrom, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isDisjointFrom : Symbol(Set.isDisjointFrom, Decl(lib.esnext.collection.d.ts, --, --)) +>Set : Symbol(Set, 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, --, --)) + +numberSet.isDisjointFrom(stringSet); +>numberSet.isDisjointFrom : Symbol(Set.isDisjointFrom, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isDisjointFrom : Symbol(Set.isDisjointFrom, Decl(lib.esnext.collection.d.ts, --, --)) +>stringSet : Symbol(stringSet, Decl(setMethods.ts, 2, 3)) + +numberSet.isDisjointFrom(numberMap); +>numberSet.isDisjointFrom : Symbol(Set.isDisjointFrom, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isDisjointFrom : Symbol(Set.isDisjointFrom, Decl(lib.esnext.collection.d.ts, --, --)) +>numberMap : Symbol(numberMap, Decl(setMethods.ts, 4, 3)) + +numberSet.isDisjointFrom(numberSetLike); +>numberSet.isDisjointFrom : Symbol(Set.isDisjointFrom, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSet : Symbol(numberSet, Decl(setMethods.ts, 0, 3)) +>isDisjointFrom : Symbol(Set.isDisjointFrom, Decl(lib.esnext.collection.d.ts, --, --)) +>numberSetLike : Symbol(numberSetLike, Decl(setMethods.ts, 6, 3)) + diff --git a/tests/baselines/reference/setMethods.types b/tests/baselines/reference/setMethods.types new file mode 100644 index 0000000000000..1ffc6603869dd --- /dev/null +++ b/tests/baselines/reference/setMethods.types @@ -0,0 +1,306 @@ +//// [tests/cases/compiler/setMethods.ts] //// + +=== setMethods.ts === +let numberSet = new Set([0, 1, 2]); +>numberSet : Set +>new Set([0, 1, 2]) : Set +>Set : SetConstructor +>[0, 1, 2] : number[] +>0 : 0 +>1 : 1 +>2 : 2 + +let stringSet = new Set(["a", "b"]); +>stringSet : Set +>new Set(["a", "b"]) : Set +>Set : SetConstructor +>["a", "b"] : string[] +>"a" : "a" +>"b" : "b" + +let numberMap = new Map([[4, {}], [5, {}]]); +>numberMap : Map +>new Map([[4, {}], [5, {}]]) : Map +>Map : MapConstructor +>[[4, {}], [5, {}]] : [number, {}][] +>[4, {}] : [number, {}] +>4 : 4 +>{} : {} +>[5, {}] : [number, {}] +>5 : 5 +>{} : {} + +let numberSetLike = { +>numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } +>{ size: 1, *keys() { yield 3 }, has(x) { return x === 3 },} : { size: number; keys(): Generator; has(x: any): boolean; } + + size: 1, +>size : number +>1 : 1 + + *keys() { yield 3 }, +>keys : () => Generator +>yield 3 : any +>3 : 3 + + has(x) { return x === 3 }, +>has : (x: any) => boolean +>x : any +>x === 3 : boolean +>x : any +>3 : 3 + +}; + +numberSet.union([]); +>numberSet.union([]) : Set +>numberSet.union : (other: SetLike) => Set +>numberSet : Set +>union : (other: SetLike) => Set +>[] : undefined[] + +numberSet.union(new Set); +>numberSet.union(new Set) : Set +>numberSet.union : (other: SetLike) => Set +>numberSet : Set +>union : (other: SetLike) => Set +>new Set : Set +>Set : SetConstructor + +numberSet.union(stringSet); +>numberSet.union(stringSet) : Set +>numberSet.union : (other: SetLike) => Set +>numberSet : Set +>union : (other: SetLike) => Set +>stringSet : Set + +numberSet.union(numberMap); +>numberSet.union(numberMap) : Set +>numberSet.union : (other: SetLike) => Set +>numberSet : Set +>union : (other: SetLike) => Set +>numberMap : Map + +numberSet.union(numberSetLike); +>numberSet.union(numberSetLike) : Set +>numberSet.union : (other: SetLike) => Set +>numberSet : Set +>union : (other: SetLike) => Set +>numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } + +numberSet.intersection([]); +>numberSet.intersection([]) : Set +>numberSet.intersection : (other: SetLike) => Set +>numberSet : Set +>intersection : (other: SetLike) => Set +>[] : undefined[] + +numberSet.intersection(new Set); +>numberSet.intersection(new Set) : Set +>numberSet.intersection : (other: SetLike) => Set +>numberSet : Set +>intersection : (other: SetLike) => Set +>new Set : Set +>Set : SetConstructor + +numberSet.intersection(stringSet); +>numberSet.intersection(stringSet) : Set +>numberSet.intersection : (other: SetLike) => Set +>numberSet : Set +>intersection : (other: SetLike) => Set +>stringSet : Set + +numberSet.intersection(numberMap); +>numberSet.intersection(numberMap) : Set +>numberSet.intersection : (other: SetLike) => Set +>numberSet : Set +>intersection : (other: SetLike) => Set +>numberMap : Map + +numberSet.intersection(numberSetLike); +>numberSet.intersection(numberSetLike) : Set +>numberSet.intersection : (other: SetLike) => Set +>numberSet : Set +>intersection : (other: SetLike) => Set +>numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } + +numberSet.difference([]); +>numberSet.difference([]) : Set +>numberSet.difference : (other: SetLike) => Set +>numberSet : Set +>difference : (other: SetLike) => Set +>[] : undefined[] + +numberSet.difference(new Set); +>numberSet.difference(new Set) : Set +>numberSet.difference : (other: SetLike) => Set +>numberSet : Set +>difference : (other: SetLike) => Set +>new Set : Set +>Set : SetConstructor + +numberSet.difference(stringSet); +>numberSet.difference(stringSet) : Set +>numberSet.difference : (other: SetLike) => Set +>numberSet : Set +>difference : (other: SetLike) => Set +>stringSet : Set + +numberSet.difference(numberMap); +>numberSet.difference(numberMap) : Set +>numberSet.difference : (other: SetLike) => Set +>numberSet : Set +>difference : (other: SetLike) => Set +>numberMap : Map + +numberSet.difference(numberSetLike); +>numberSet.difference(numberSetLike) : Set +>numberSet.difference : (other: SetLike) => Set +>numberSet : Set +>difference : (other: SetLike) => Set +>numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } + +numberSet.symmetricDifference([]); +>numberSet.symmetricDifference([]) : Set +>numberSet.symmetricDifference : (other: SetLike) => Set +>numberSet : Set +>symmetricDifference : (other: SetLike) => Set +>[] : undefined[] + +numberSet.symmetricDifference(new Set); +>numberSet.symmetricDifference(new Set) : Set +>numberSet.symmetricDifference : (other: SetLike) => Set +>numberSet : Set +>symmetricDifference : (other: SetLike) => Set +>new Set : Set +>Set : SetConstructor + +numberSet.symmetricDifference(stringSet); +>numberSet.symmetricDifference(stringSet) : Set +>numberSet.symmetricDifference : (other: SetLike) => Set +>numberSet : Set +>symmetricDifference : (other: SetLike) => Set +>stringSet : Set + +numberSet.symmetricDifference(numberMap); +>numberSet.symmetricDifference(numberMap) : Set +>numberSet.symmetricDifference : (other: SetLike) => Set +>numberSet : Set +>symmetricDifference : (other: SetLike) => Set +>numberMap : Map + +numberSet.symmetricDifference(numberSetLike); +>numberSet.symmetricDifference(numberSetLike) : Set +>numberSet.symmetricDifference : (other: SetLike) => Set +>numberSet : Set +>symmetricDifference : (other: SetLike) => Set +>numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } + +numberSet.isSubsetOf([]); +>numberSet.isSubsetOf([]) : Set +>numberSet.isSubsetOf : (other: SetLike) => Set +>numberSet : Set +>isSubsetOf : (other: SetLike) => Set +>[] : undefined[] + +numberSet.isSubsetOf(new Set); +>numberSet.isSubsetOf(new Set) : Set +>numberSet.isSubsetOf : (other: SetLike) => Set +>numberSet : Set +>isSubsetOf : (other: SetLike) => Set +>new Set : Set +>Set : SetConstructor + +numberSet.isSubsetOf(stringSet); +>numberSet.isSubsetOf(stringSet) : Set +>numberSet.isSubsetOf : (other: SetLike) => Set +>numberSet : Set +>isSubsetOf : (other: SetLike) => Set +>stringSet : Set + +numberSet.isSubsetOf(numberMap); +>numberSet.isSubsetOf(numberMap) : Set +>numberSet.isSubsetOf : (other: SetLike) => Set +>numberSet : Set +>isSubsetOf : (other: SetLike) => Set +>numberMap : Map + +numberSet.isSubsetOf(numberSetLike); +>numberSet.isSubsetOf(numberSetLike) : Set +>numberSet.isSubsetOf : (other: SetLike) => Set +>numberSet : Set +>isSubsetOf : (other: SetLike) => Set +>numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } + +numberSet.isSupersetOf([]); +>numberSet.isSupersetOf([]) : Set +>numberSet.isSupersetOf : (other: SetLike) => Set +>numberSet : Set +>isSupersetOf : (other: SetLike) => Set +>[] : undefined[] + +numberSet.isSupersetOf(new Set); +>numberSet.isSupersetOf(new Set) : Set +>numberSet.isSupersetOf : (other: SetLike) => Set +>numberSet : Set +>isSupersetOf : (other: SetLike) => Set +>new Set : Set +>Set : SetConstructor + +numberSet.isSupersetOf(stringSet); +>numberSet.isSupersetOf(stringSet) : Set +>numberSet.isSupersetOf : (other: SetLike) => Set +>numberSet : Set +>isSupersetOf : (other: SetLike) => Set +>stringSet : Set + +numberSet.isSupersetOf(numberMap); +>numberSet.isSupersetOf(numberMap) : Set +>numberSet.isSupersetOf : (other: SetLike) => Set +>numberSet : Set +>isSupersetOf : (other: SetLike) => Set +>numberMap : Map + +numberSet.isSupersetOf(numberSetLike); +>numberSet.isSupersetOf(numberSetLike) : Set +>numberSet.isSupersetOf : (other: SetLike) => Set +>numberSet : Set +>isSupersetOf : (other: SetLike) => Set +>numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } + +numberSet.isDisjointFrom([]); +>numberSet.isDisjointFrom([]) : Set +>numberSet.isDisjointFrom : (other: SetLike) => Set +>numberSet : Set +>isDisjointFrom : (other: SetLike) => Set +>[] : undefined[] + +numberSet.isDisjointFrom(new Set); +>numberSet.isDisjointFrom(new Set) : Set +>numberSet.isDisjointFrom : (other: SetLike) => Set +>numberSet : Set +>isDisjointFrom : (other: SetLike) => Set +>new Set : Set +>Set : SetConstructor + +numberSet.isDisjointFrom(stringSet); +>numberSet.isDisjointFrom(stringSet) : Set +>numberSet.isDisjointFrom : (other: SetLike) => Set +>numberSet : Set +>isDisjointFrom : (other: SetLike) => Set +>stringSet : Set + +numberSet.isDisjointFrom(numberMap); +>numberSet.isDisjointFrom(numberMap) : Set +>numberSet.isDisjointFrom : (other: SetLike) => Set +>numberSet : Set +>isDisjointFrom : (other: SetLike) => Set +>numberMap : Map + +numberSet.isDisjointFrom(numberSetLike); +>numberSet.isDisjointFrom(numberSetLike) : Set +>numberSet.isDisjointFrom : (other: SetLike) => Set +>numberSet : Set +>isDisjointFrom : (other: SetLike) => Set +>numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } + diff --git a/tests/cases/compiler/setMethods.ts b/tests/cases/compiler/setMethods.ts new file mode 100644 index 0000000000000..14743ce8c2dfa --- /dev/null +++ b/tests/cases/compiler/setMethods.ts @@ -0,0 +1,55 @@ +// @target: esnext + +let numberSet = new Set([0, 1, 2]); + +let stringSet = new Set(["a", "b"]); + +let numberMap = new Map([[4, {}], [5, {}]]); + +let numberSetLike = { + size: 1, + *keys() { yield 3 }, + has(x) { return x === 3 }, +}; + +numberSet.union([]); +numberSet.union(new Set); +numberSet.union(stringSet); +numberSet.union(numberMap); +numberSet.union(numberSetLike); + +numberSet.intersection([]); +numberSet.intersection(new Set); +numberSet.intersection(stringSet); +numberSet.intersection(numberMap); +numberSet.intersection(numberSetLike); + +numberSet.difference([]); +numberSet.difference(new Set); +numberSet.difference(stringSet); +numberSet.difference(numberMap); +numberSet.difference(numberSetLike); + +numberSet.symmetricDifference([]); +numberSet.symmetricDifference(new Set); +numberSet.symmetricDifference(stringSet); +numberSet.symmetricDifference(numberMap); +numberSet.symmetricDifference(numberSetLike); + +numberSet.isSubsetOf([]); +numberSet.isSubsetOf(new Set); +numberSet.isSubsetOf(stringSet); +numberSet.isSubsetOf(numberMap); +numberSet.isSubsetOf(numberSetLike); + +numberSet.isSupersetOf([]); +numberSet.isSupersetOf(new Set); +numberSet.isSupersetOf(stringSet); +numberSet.isSupersetOf(numberMap); +numberSet.isSupersetOf(numberSetLike); + +numberSet.isDisjointFrom([]); +numberSet.isDisjointFrom(new Set); +numberSet.isDisjointFrom(stringSet); +numberSet.isDisjointFrom(numberMap); +numberSet.isDisjointFrom(numberSetLike); From d9efe9618eab17785c35964dd44f0699ac01c5f7 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 29 Jan 2024 23:20:57 -0800 Subject: [PATCH 2/8] run/commit all baselines --- ...tClassWithMemberCalledTheSameAsItsOwnTypeParam.symbols | 2 +- .../reference/esNextWeakRefs_IterableWeakMap.symbols | 4 ++-- tests/baselines/reference/extendsTag1.symbols | 2 +- tests/baselines/reference/mapGroupBy.symbols | 4 ++-- tests/baselines/reference/objectGroupBy.symbols | 4 ++-- .../reference/substitutionTypePassedToExtends.symbols | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/baselines/reference/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.symbols b/tests/baselines/reference/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.symbols index dca9748d6539b..6fa8dff64ed86 100644 --- a/tests/baselines/reference/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.symbols +++ b/tests/baselines/reference/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.symbols @@ -69,7 +69,7 @@ export abstract class BaseObservable extends ConvenientObserv protected readonly observers = new Set(); >observers : Symbol(BaseObservable.observers, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 18, 98)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) >IObserver : Symbol(IObserver, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 0, 0)) } diff --git a/tests/baselines/reference/esNextWeakRefs_IterableWeakMap.symbols b/tests/baselines/reference/esNextWeakRefs_IterableWeakMap.symbols index 5af85b38568d1..22f9533da2564 100644 --- a/tests/baselines/reference/esNextWeakRefs_IterableWeakMap.symbols +++ b/tests/baselines/reference/esNextWeakRefs_IterableWeakMap.symbols @@ -13,7 +13,7 @@ const IterableWeakMap_cleanup = ({ ref, set }: { readonly set: Set>; >set : Symbol(set, Decl(esNextWeakRefs_IterableWeakMap.ts, 2, 34)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) >WeakRef : Symbol(WeakRef, Decl(lib.es2021.weakref.d.ts, --, --), Decl(lib.es2021.weakref.d.ts, --, --)) }) => { @@ -52,7 +52,7 @@ export class IterableWeakMap implements WeakMap { #refSet = new Set>(); >#refSet : Symbol(IterableWeakMap.#refSet, Decl(esNextWeakRefs_IterableWeakMap.ts, 12, 72)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) >WeakRef : Symbol(WeakRef, Decl(lib.es2021.weakref.d.ts, --, --), Decl(lib.es2021.weakref.d.ts, --, --)) >K : Symbol(K, Decl(esNextWeakRefs_IterableWeakMap.ts, 9, 29)) diff --git a/tests/baselines/reference/extendsTag1.symbols b/tests/baselines/reference/extendsTag1.symbols index 740f835a96b9c..f83b253d0e459 100644 --- a/tests/baselines/reference/extendsTag1.symbols +++ b/tests/baselines/reference/extendsTag1.symbols @@ -7,5 +7,5 @@ */ class My extends Set {} >My : Symbol(My, Decl(bug25101.js, 0, 0)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) diff --git a/tests/baselines/reference/mapGroupBy.symbols b/tests/baselines/reference/mapGroupBy.symbols index 4905d158fc9d8..356b4e680baf4 100644 --- a/tests/baselines/reference/mapGroupBy.symbols +++ b/tests/baselines/reference/mapGroupBy.symbols @@ -24,9 +24,9 @@ type Employee = { name: string, role: 'ic' | 'manager' } const employees: Set = new Set(); >employees : Symbol(employees, Decl(mapGroupBy.ts, 5, 5)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) >Employee : Symbol(Employee, Decl(mapGroupBy.ts, 2, 46)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) const byRole = Map.groupBy(employees, x => x.role); >byRole : Symbol(byRole, Decl(mapGroupBy.ts, 6, 5)) diff --git a/tests/baselines/reference/objectGroupBy.symbols b/tests/baselines/reference/objectGroupBy.symbols index df5e44fbf3c16..ef3c9a68f7ef6 100644 --- a/tests/baselines/reference/objectGroupBy.symbols +++ b/tests/baselines/reference/objectGroupBy.symbols @@ -24,9 +24,9 @@ type Employee = { name: string, role: 'ic' | 'manager' } const employees: Set = new Set(); >employees : Symbol(employees, Decl(objectGroupBy.ts, 5, 5)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) >Employee : Symbol(Employee, Decl(objectGroupBy.ts, 2, 49)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) const byRole = Object.groupBy(employees, x => x.role); >byRole : Symbol(byRole, Decl(objectGroupBy.ts, 6, 5)) diff --git a/tests/baselines/reference/substitutionTypePassedToExtends.symbols b/tests/baselines/reference/substitutionTypePassedToExtends.symbols index 8d09a8e282f9c..74d2d650efcc4 100644 --- a/tests/baselines/reference/substitutionTypePassedToExtends.symbols +++ b/tests/baselines/reference/substitutionTypePassedToExtends.symbols @@ -19,16 +19,16 @@ type Bar1 = T type Foo2 = Set extends Set ? Bar2> : 'else' >Foo2 : Symbol(Foo2, Decl(substitutionTypePassedToExtends.ts, 1, 36)) >A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 3, 10)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) >A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 3, 10)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) >Bar2 : Symbol(Bar2, Decl(substitutionTypePassedToExtends.ts, 3, 68)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) >A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 3, 10)) type Bar2> = T >Bar2 : Symbol(Bar2, Decl(substitutionTypePassedToExtends.ts, 3, 68)) >T : Symbol(T, Decl(substitutionTypePassedToExtends.ts, 4, 10)) ->Set : Symbol(Set, 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, --, --)) +>Set : Symbol(Set, 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, --, --)) >T : Symbol(T, Decl(substitutionTypePassedToExtends.ts, 4, 10)) From 82378a9b6bf09b605f0314c631135686c16036eb Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Wed, 31 Jan 2024 22:11:56 -0800 Subject: [PATCH 3/8] update types --- src/lib/esnext.collection.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/esnext.collection.d.ts b/src/lib/esnext.collection.d.ts index 95be718e43837..9adc46f32eef7 100644 --- a/src/lib/esnext.collection.d.ts +++ b/src/lib/esnext.collection.d.ts @@ -10,7 +10,7 @@ interface MapConstructor { ): Map; } -interface SetLike { +interface ReadonlySetLike { /** * Despite its name, returns an iterable of the values in the set-like. */ @@ -29,29 +29,29 @@ interface Set { /** * @returns a new Set containing all the elements in this Set and also all the elements in the argument. */ - union(other: SetLike): Set; + union(other: ReadonlySetLike): Set; /** * @returns a new Set containing all the elements which are both in this Set and in the argument. */ - intersection(other: SetLike): Set; + intersection(other: ReadonlySetLike): Set; /** * @returns a new Set containing all the elements in this Set which are not also in the argument. */ - difference(other: SetLike): Set; + difference(other: ReadonlySetLike): Set; /** * @returns a new Set containing all the elements in this Set which are in this or in the argument, but not in both. */ - symmetricDifference(other: SetLike): Set; + symmetricDifference(other: ReadonlySetLike): Set; /** * @returns a boolean indicating whether all the elements in this Set are also in the argument. */ - isSubsetOf(other: SetLike): Set; + isSubsetOf(other: ReadonlySetLike): boolean; /** * @returns a boolean indicating whether all the elements in the argument are also in this Set. */ - isSupersetOf(other: SetLike): Set; + isSupersetOf(other: ReadonlySetLike): boolean; /** * @returns a boolean indicating whether this Set has no elements in common with the argument. */ - isDisjointFrom(other: SetLike): Set; + isDisjointFrom(other: ReadonlySetLike): boolean; } From 623976202ddeddce840adaf207b89550be5fc085 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Wed, 31 Jan 2024 22:14:57 -0800 Subject: [PATCH 4/8] update baselines --- .../baselines/reference/setMethods.errors.txt | 65 ++---- tests/baselines/reference/setMethods.types | 204 +++++++++--------- 2 files changed, 119 insertions(+), 150 deletions(-) diff --git a/tests/baselines/reference/setMethods.errors.txt b/tests/baselines/reference/setMethods.errors.txt index 4d6b227d46ebe..dc46f007ec67f 100644 --- a/tests/baselines/reference/setMethods.errors.txt +++ b/tests/baselines/reference/setMethods.errors.txt @@ -1,26 +1,14 @@ -setMethods.ts(13,17): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. - Type 'undefined[]' is missing the following properties from type 'SetLike': has, size -setMethods.ts(15,17): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. - The types returned by 'keys()[Symbol.iterator]().next(...)' are incompatible between these types. - Type 'IteratorResult' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. - Type 'string' is not assignable to type 'number'. -setMethods.ts(19,24): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. -setMethods.ts(21,24): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. -setMethods.ts(25,22): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. -setMethods.ts(27,22): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. -setMethods.ts(31,31): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. -setMethods.ts(33,31): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. -setMethods.ts(37,22): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. -setMethods.ts(39,22): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. -setMethods.ts(43,24): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. -setMethods.ts(45,24): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. -setMethods.ts(49,26): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. -setMethods.ts(51,26): error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. +setMethods.ts(13,17): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. + Type 'undefined[]' is missing the following properties from type 'ReadonlySetLike': has, size +setMethods.ts(19,24): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. +setMethods.ts(25,22): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. +setMethods.ts(31,31): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. +setMethods.ts(37,22): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. +setMethods.ts(43,24): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. +setMethods.ts(49,26): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. -==== setMethods.ts (14 errors) ==== +==== setMethods.ts (7 errors) ==== let numberSet = new Set([0, 1, 2]); let stringSet = new Set(["a", "b"]); @@ -35,77 +23,58 @@ setMethods.ts(51,26): error TS2345: Argument of type 'Set' is not assign numberSet.union([]); ~~ -!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. -!!! error TS2345: Type 'undefined[]' is missing the following properties from type 'SetLike': has, size +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. +!!! error TS2345: Type 'undefined[]' is missing the following properties from type 'ReadonlySetLike': has, size numberSet.union(new Set); numberSet.union(stringSet); - ~~~~~~~~~ -!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. -!!! error TS2345: The types returned by 'keys()[Symbol.iterator]().next(...)' are incompatible between these types. -!!! error TS2345: Type 'IteratorResult' is not assignable to type 'IteratorResult'. -!!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. -!!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. -!!! error TS2345: Type 'string' is not assignable to type 'number'. numberSet.union(numberMap); numberSet.union(numberSetLike); numberSet.intersection([]); ~~ -!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. numberSet.intersection(new Set); numberSet.intersection(stringSet); - ~~~~~~~~~ -!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. numberSet.intersection(numberMap); numberSet.intersection(numberSetLike); numberSet.difference([]); ~~ -!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. numberSet.difference(new Set); numberSet.difference(stringSet); - ~~~~~~~~~ -!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. numberSet.difference(numberMap); numberSet.difference(numberSetLike); numberSet.symmetricDifference([]); ~~ -!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. numberSet.symmetricDifference(new Set); numberSet.symmetricDifference(stringSet); - ~~~~~~~~~ -!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. numberSet.symmetricDifference(numberMap); numberSet.symmetricDifference(numberSetLike); numberSet.isSubsetOf([]); ~~ -!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. numberSet.isSubsetOf(new Set); numberSet.isSubsetOf(stringSet); - ~~~~~~~~~ -!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. numberSet.isSubsetOf(numberMap); numberSet.isSubsetOf(numberSetLike); numberSet.isSupersetOf([]); ~~ -!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. numberSet.isSupersetOf(new Set); numberSet.isSupersetOf(stringSet); - ~~~~~~~~~ -!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. numberSet.isSupersetOf(numberMap); numberSet.isSupersetOf(numberSetLike); numberSet.isDisjointFrom([]); ~~ -!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'SetLike'. +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. numberSet.isDisjointFrom(new Set); numberSet.isDisjointFrom(stringSet); - ~~~~~~~~~ -!!! error TS2345: Argument of type 'Set' is not assignable to parameter of type 'SetLike'. numberSet.isDisjointFrom(numberMap); numberSet.isDisjointFrom(numberSetLike); \ No newline at end of file diff --git a/tests/baselines/reference/setMethods.types b/tests/baselines/reference/setMethods.types index 1ffc6603869dd..0096b4546be4e 100644 --- a/tests/baselines/reference/setMethods.types +++ b/tests/baselines/reference/setMethods.types @@ -53,254 +53,254 @@ let numberSetLike = { }; numberSet.union([]); ->numberSet.union([]) : Set ->numberSet.union : (other: SetLike) => Set +>numberSet.union([]) : Set +>numberSet.union : (other: ReadonlySetLike) => Set >numberSet : Set ->union : (other: SetLike) => Set +>union : (other: ReadonlySetLike) => Set >[] : undefined[] numberSet.union(new Set); ->numberSet.union(new Set) : Set ->numberSet.union : (other: SetLike) => Set +>numberSet.union(new Set) : Set +>numberSet.union : (other: ReadonlySetLike) => Set >numberSet : Set ->union : (other: SetLike) => Set ->new Set : Set +>union : (other: ReadonlySetLike) => Set +>new Set : Set >Set : SetConstructor numberSet.union(stringSet); ->numberSet.union(stringSet) : Set ->numberSet.union : (other: SetLike) => Set +>numberSet.union(stringSet) : Set +>numberSet.union : (other: ReadonlySetLike) => Set >numberSet : Set ->union : (other: SetLike) => Set +>union : (other: ReadonlySetLike) => Set >stringSet : Set numberSet.union(numberMap); >numberSet.union(numberMap) : Set ->numberSet.union : (other: SetLike) => Set +>numberSet.union : (other: ReadonlySetLike) => Set >numberSet : Set ->union : (other: SetLike) => Set +>union : (other: ReadonlySetLike) => Set >numberMap : Map numberSet.union(numberSetLike); ->numberSet.union(numberSetLike) : Set ->numberSet.union : (other: SetLike) => Set +>numberSet.union(numberSetLike) : Set +>numberSet.union : (other: ReadonlySetLike) => Set >numberSet : Set ->union : (other: SetLike) => Set +>union : (other: ReadonlySetLike) => Set >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } numberSet.intersection([]); >numberSet.intersection([]) : Set ->numberSet.intersection : (other: SetLike) => Set +>numberSet.intersection : (other: ReadonlySetLike) => Set >numberSet : Set ->intersection : (other: SetLike) => Set +>intersection : (other: ReadonlySetLike) => Set >[] : undefined[] numberSet.intersection(new Set); >numberSet.intersection(new Set) : Set ->numberSet.intersection : (other: SetLike) => Set +>numberSet.intersection : (other: ReadonlySetLike) => Set >numberSet : Set ->intersection : (other: SetLike) => Set ->new Set : Set +>intersection : (other: ReadonlySetLike) => Set +>new Set : Set >Set : SetConstructor numberSet.intersection(stringSet); ->numberSet.intersection(stringSet) : Set ->numberSet.intersection : (other: SetLike) => Set +>numberSet.intersection(stringSet) : Set +>numberSet.intersection : (other: ReadonlySetLike) => Set >numberSet : Set ->intersection : (other: SetLike) => Set +>intersection : (other: ReadonlySetLike) => Set >stringSet : Set numberSet.intersection(numberMap); >numberSet.intersection(numberMap) : Set ->numberSet.intersection : (other: SetLike) => Set +>numberSet.intersection : (other: ReadonlySetLike) => Set >numberSet : Set ->intersection : (other: SetLike) => Set +>intersection : (other: ReadonlySetLike) => Set >numberMap : Map numberSet.intersection(numberSetLike); ->numberSet.intersection(numberSetLike) : Set ->numberSet.intersection : (other: SetLike) => Set +>numberSet.intersection(numberSetLike) : Set +>numberSet.intersection : (other: ReadonlySetLike) => Set >numberSet : Set ->intersection : (other: SetLike) => Set +>intersection : (other: ReadonlySetLike) => Set >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } numberSet.difference([]); >numberSet.difference([]) : Set ->numberSet.difference : (other: SetLike) => Set +>numberSet.difference : (other: ReadonlySetLike) => Set >numberSet : Set ->difference : (other: SetLike) => Set +>difference : (other: ReadonlySetLike) => Set >[] : undefined[] numberSet.difference(new Set); >numberSet.difference(new Set) : Set ->numberSet.difference : (other: SetLike) => Set +>numberSet.difference : (other: ReadonlySetLike) => Set >numberSet : Set ->difference : (other: SetLike) => Set ->new Set : Set +>difference : (other: ReadonlySetLike) => Set +>new Set : Set >Set : SetConstructor numberSet.difference(stringSet); >numberSet.difference(stringSet) : Set ->numberSet.difference : (other: SetLike) => Set +>numberSet.difference : (other: ReadonlySetLike) => Set >numberSet : Set ->difference : (other: SetLike) => Set +>difference : (other: ReadonlySetLike) => Set >stringSet : Set numberSet.difference(numberMap); >numberSet.difference(numberMap) : Set ->numberSet.difference : (other: SetLike) => Set +>numberSet.difference : (other: ReadonlySetLike) => Set >numberSet : Set ->difference : (other: SetLike) => Set +>difference : (other: ReadonlySetLike) => Set >numberMap : Map numberSet.difference(numberSetLike); >numberSet.difference(numberSetLike) : Set ->numberSet.difference : (other: SetLike) => Set +>numberSet.difference : (other: ReadonlySetLike) => Set >numberSet : Set ->difference : (other: SetLike) => Set +>difference : (other: ReadonlySetLike) => Set >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } numberSet.symmetricDifference([]); ->numberSet.symmetricDifference([]) : Set ->numberSet.symmetricDifference : (other: SetLike) => Set +>numberSet.symmetricDifference([]) : Set +>numberSet.symmetricDifference : (other: ReadonlySetLike) => Set >numberSet : Set ->symmetricDifference : (other: SetLike) => Set +>symmetricDifference : (other: ReadonlySetLike) => Set >[] : undefined[] numberSet.symmetricDifference(new Set); ->numberSet.symmetricDifference(new Set) : Set ->numberSet.symmetricDifference : (other: SetLike) => Set +>numberSet.symmetricDifference(new Set) : Set +>numberSet.symmetricDifference : (other: ReadonlySetLike) => Set >numberSet : Set ->symmetricDifference : (other: SetLike) => Set ->new Set : Set +>symmetricDifference : (other: ReadonlySetLike) => Set +>new Set : Set >Set : SetConstructor numberSet.symmetricDifference(stringSet); ->numberSet.symmetricDifference(stringSet) : Set ->numberSet.symmetricDifference : (other: SetLike) => Set +>numberSet.symmetricDifference(stringSet) : Set +>numberSet.symmetricDifference : (other: ReadonlySetLike) => Set >numberSet : Set ->symmetricDifference : (other: SetLike) => Set +>symmetricDifference : (other: ReadonlySetLike) => Set >stringSet : Set numberSet.symmetricDifference(numberMap); >numberSet.symmetricDifference(numberMap) : Set ->numberSet.symmetricDifference : (other: SetLike) => Set +>numberSet.symmetricDifference : (other: ReadonlySetLike) => Set >numberSet : Set ->symmetricDifference : (other: SetLike) => Set +>symmetricDifference : (other: ReadonlySetLike) => Set >numberMap : Map numberSet.symmetricDifference(numberSetLike); ->numberSet.symmetricDifference(numberSetLike) : Set ->numberSet.symmetricDifference : (other: SetLike) => Set +>numberSet.symmetricDifference(numberSetLike) : Set +>numberSet.symmetricDifference : (other: ReadonlySetLike) => Set >numberSet : Set ->symmetricDifference : (other: SetLike) => Set +>symmetricDifference : (other: ReadonlySetLike) => Set >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } numberSet.isSubsetOf([]); ->numberSet.isSubsetOf([]) : Set ->numberSet.isSubsetOf : (other: SetLike) => Set +>numberSet.isSubsetOf([]) : boolean +>numberSet.isSubsetOf : (other: ReadonlySetLike) => boolean >numberSet : Set ->isSubsetOf : (other: SetLike) => Set +>isSubsetOf : (other: ReadonlySetLike) => boolean >[] : undefined[] numberSet.isSubsetOf(new Set); ->numberSet.isSubsetOf(new Set) : Set ->numberSet.isSubsetOf : (other: SetLike) => Set +>numberSet.isSubsetOf(new Set) : boolean +>numberSet.isSubsetOf : (other: ReadonlySetLike) => boolean >numberSet : Set ->isSubsetOf : (other: SetLike) => Set ->new Set : Set +>isSubsetOf : (other: ReadonlySetLike) => boolean +>new Set : Set >Set : SetConstructor numberSet.isSubsetOf(stringSet); ->numberSet.isSubsetOf(stringSet) : Set ->numberSet.isSubsetOf : (other: SetLike) => Set +>numberSet.isSubsetOf(stringSet) : boolean +>numberSet.isSubsetOf : (other: ReadonlySetLike) => boolean >numberSet : Set ->isSubsetOf : (other: SetLike) => Set +>isSubsetOf : (other: ReadonlySetLike) => boolean >stringSet : Set numberSet.isSubsetOf(numberMap); ->numberSet.isSubsetOf(numberMap) : Set ->numberSet.isSubsetOf : (other: SetLike) => Set +>numberSet.isSubsetOf(numberMap) : boolean +>numberSet.isSubsetOf : (other: ReadonlySetLike) => boolean >numberSet : Set ->isSubsetOf : (other: SetLike) => Set +>isSubsetOf : (other: ReadonlySetLike) => boolean >numberMap : Map numberSet.isSubsetOf(numberSetLike); ->numberSet.isSubsetOf(numberSetLike) : Set ->numberSet.isSubsetOf : (other: SetLike) => Set +>numberSet.isSubsetOf(numberSetLike) : boolean +>numberSet.isSubsetOf : (other: ReadonlySetLike) => boolean >numberSet : Set ->isSubsetOf : (other: SetLike) => Set +>isSubsetOf : (other: ReadonlySetLike) => boolean >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } numberSet.isSupersetOf([]); ->numberSet.isSupersetOf([]) : Set ->numberSet.isSupersetOf : (other: SetLike) => Set +>numberSet.isSupersetOf([]) : boolean +>numberSet.isSupersetOf : (other: ReadonlySetLike) => boolean >numberSet : Set ->isSupersetOf : (other: SetLike) => Set +>isSupersetOf : (other: ReadonlySetLike) => boolean >[] : undefined[] numberSet.isSupersetOf(new Set); ->numberSet.isSupersetOf(new Set) : Set ->numberSet.isSupersetOf : (other: SetLike) => Set +>numberSet.isSupersetOf(new Set) : boolean +>numberSet.isSupersetOf : (other: ReadonlySetLike) => boolean >numberSet : Set ->isSupersetOf : (other: SetLike) => Set ->new Set : Set +>isSupersetOf : (other: ReadonlySetLike) => boolean +>new Set : Set >Set : SetConstructor numberSet.isSupersetOf(stringSet); ->numberSet.isSupersetOf(stringSet) : Set ->numberSet.isSupersetOf : (other: SetLike) => Set +>numberSet.isSupersetOf(stringSet) : boolean +>numberSet.isSupersetOf : (other: ReadonlySetLike) => boolean >numberSet : Set ->isSupersetOf : (other: SetLike) => Set +>isSupersetOf : (other: ReadonlySetLike) => boolean >stringSet : Set numberSet.isSupersetOf(numberMap); ->numberSet.isSupersetOf(numberMap) : Set ->numberSet.isSupersetOf : (other: SetLike) => Set +>numberSet.isSupersetOf(numberMap) : boolean +>numberSet.isSupersetOf : (other: ReadonlySetLike) => boolean >numberSet : Set ->isSupersetOf : (other: SetLike) => Set +>isSupersetOf : (other: ReadonlySetLike) => boolean >numberMap : Map numberSet.isSupersetOf(numberSetLike); ->numberSet.isSupersetOf(numberSetLike) : Set ->numberSet.isSupersetOf : (other: SetLike) => Set +>numberSet.isSupersetOf(numberSetLike) : boolean +>numberSet.isSupersetOf : (other: ReadonlySetLike) => boolean >numberSet : Set ->isSupersetOf : (other: SetLike) => Set +>isSupersetOf : (other: ReadonlySetLike) => boolean >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } numberSet.isDisjointFrom([]); ->numberSet.isDisjointFrom([]) : Set ->numberSet.isDisjointFrom : (other: SetLike) => Set +>numberSet.isDisjointFrom([]) : boolean +>numberSet.isDisjointFrom : (other: ReadonlySetLike) => boolean >numberSet : Set ->isDisjointFrom : (other: SetLike) => Set +>isDisjointFrom : (other: ReadonlySetLike) => boolean >[] : undefined[] numberSet.isDisjointFrom(new Set); ->numberSet.isDisjointFrom(new Set) : Set ->numberSet.isDisjointFrom : (other: SetLike) => Set +>numberSet.isDisjointFrom(new Set) : boolean +>numberSet.isDisjointFrom : (other: ReadonlySetLike) => boolean >numberSet : Set ->isDisjointFrom : (other: SetLike) => Set ->new Set : Set +>isDisjointFrom : (other: ReadonlySetLike) => boolean +>new Set : Set >Set : SetConstructor numberSet.isDisjointFrom(stringSet); ->numberSet.isDisjointFrom(stringSet) : Set ->numberSet.isDisjointFrom : (other: SetLike) => Set +>numberSet.isDisjointFrom(stringSet) : boolean +>numberSet.isDisjointFrom : (other: ReadonlySetLike) => boolean >numberSet : Set ->isDisjointFrom : (other: SetLike) => Set +>isDisjointFrom : (other: ReadonlySetLike) => boolean >stringSet : Set numberSet.isDisjointFrom(numberMap); ->numberSet.isDisjointFrom(numberMap) : Set ->numberSet.isDisjointFrom : (other: SetLike) => Set +>numberSet.isDisjointFrom(numberMap) : boolean +>numberSet.isDisjointFrom : (other: ReadonlySetLike) => boolean >numberSet : Set ->isDisjointFrom : (other: SetLike) => Set +>isDisjointFrom : (other: ReadonlySetLike) => boolean >numberMap : Map numberSet.isDisjointFrom(numberSetLike); ->numberSet.isDisjointFrom(numberSetLike) : Set ->numberSet.isDisjointFrom : (other: SetLike) => Set +>numberSet.isDisjointFrom(numberSetLike) : boolean +>numberSet.isDisjointFrom : (other: ReadonlySetLike) => boolean >numberSet : Set ->isDisjointFrom : (other: SetLike) => Set +>isDisjointFrom : (other: ReadonlySetLike) => boolean >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } From 6ceb39551a30a3aac50eb862c3f959cfc892d478 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 12 Feb 2024 11:39:53 -0800 Subject: [PATCH 5/8] fix description of symmetricDifference --- src/lib/esnext.collection.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/esnext.collection.d.ts b/src/lib/esnext.collection.d.ts index 9adc46f32eef7..d3de639c2e50b 100644 --- a/src/lib/esnext.collection.d.ts +++ b/src/lib/esnext.collection.d.ts @@ -39,7 +39,7 @@ interface Set { */ difference(other: ReadonlySetLike): Set; /** - * @returns a new Set containing all the elements in this Set which are in this or in the argument, but not in both. + * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. */ symmetricDifference(other: ReadonlySetLike): Set; /** From 9e5aca47c9f59ef92d9b4c9a6d3021eda15fc1d4 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Tue, 16 Apr 2024 13:36:57 -0700 Subject: [PATCH 6/8] fix type for keys --- src/lib/esnext.collection.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/esnext.collection.d.ts b/src/lib/esnext.collection.d.ts index d3de639c2e50b..858aa0c965cbf 100644 --- a/src/lib/esnext.collection.d.ts +++ b/src/lib/esnext.collection.d.ts @@ -12,9 +12,9 @@ interface MapConstructor { interface ReadonlySetLike { /** - * Despite its name, returns an iterable of the values in the set-like. + * Despite its name, returns an iterator of the values in the set-like. */ - keys(): Iterable; + keys(): Iterator; /** * @returns a boolean indicating whether an element with the specified value exists in the set-like or not. */ From b52312645ecd6bec484f738180fd35b37d70ba95 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Thu, 16 May 2024 08:40:47 -0700 Subject: [PATCH 7/8] update baseline --- tests/baselines/reference/setMethods.types | 217 +++++++++++++++++++++ 1 file changed, 217 insertions(+) diff --git a/tests/baselines/reference/setMethods.types b/tests/baselines/reference/setMethods.types index 0096b4546be4e..3a1d6dd950915 100644 --- a/tests/baselines/reference/setMethods.types +++ b/tests/baselines/reference/setMethods.types @@ -3,304 +3,521 @@ === setMethods.ts === let numberSet = new Set([0, 1, 2]); >numberSet : Set +> : ^^^^^^^^^^^ >new Set([0, 1, 2]) : Set +> : ^^^^^^^^^^^ >Set : SetConstructor +> : ^^^^^^^^^^^^^^ >[0, 1, 2] : number[] +> : ^^^^^^^^ >0 : 0 +> : ^ >1 : 1 +> : ^ >2 : 2 +> : ^ let stringSet = new Set(["a", "b"]); >stringSet : Set +> : ^^^^^^^^^^^ >new Set(["a", "b"]) : Set +> : ^^^^^^^^^^^ >Set : SetConstructor +> : ^^^^^^^^^^^^^^ >["a", "b"] : string[] +> : ^^^^^^^^ >"a" : "a" +> : ^^^ >"b" : "b" +> : ^^^ let numberMap = new Map([[4, {}], [5, {}]]); >numberMap : Map +> : ^^^^^^^^^^^^^^^ >new Map([[4, {}], [5, {}]]) : Map +> : ^^^^^^^^^^^^^^^ >Map : MapConstructor +> : ^^^^^^^^^^^^^^ >[[4, {}], [5, {}]] : [number, {}][] +> : ^^^^^^^^^^^^^^ >[4, {}] : [number, {}] +> : ^^^^^^^^^^^^ >4 : 4 +> : ^ >{} : {} +> : ^^ >[5, {}] : [number, {}] +> : ^^^^^^^^^^^^ >5 : 5 +> : ^ >{} : {} +> : ^^ let numberSetLike = { >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ >{ size: 1, *keys() { yield 3 }, has(x) { return x === 3 },} : { size: number; keys(): Generator; has(x: any): boolean; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ size: 1, >size : number +> : ^^^^^^ >1 : 1 +> : ^ *keys() { yield 3 }, >keys : () => Generator +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >yield 3 : any +> : ^^^ >3 : 3 +> : ^ has(x) { return x === 3 }, >has : (x: any) => boolean +> : ^ ^^^^^^^^^^^^^^^^^ >x : any +> : ^^^ >x === 3 : boolean +> : ^^^^^^^ >x : any +> : ^^^ >3 : 3 +> : ^ }; numberSet.union([]); >numberSet.union([]) : Set +> : ^^^^^^^^^^^^ >numberSet.union : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >union : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >[] : undefined[] +> : ^^^^^^^^^^^ numberSet.union(new Set); >numberSet.union(new Set) : Set +> : ^^^^^^^^^^^^ >numberSet.union : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >union : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >new Set : Set +> : ^^^^^^^^^^^^ >Set : SetConstructor +> : ^^^^^^^^^^^^^^ numberSet.union(stringSet); >numberSet.union(stringSet) : Set +> : ^^^^^^^^^^^^^^^^^^^^ >numberSet.union : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >union : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >stringSet : Set +> : ^^^^^^^^^^^ numberSet.union(numberMap); >numberSet.union(numberMap) : Set +> : ^^^^^^^^^^^ >numberSet.union : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >union : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberMap : Map +> : ^^^^^^^^^^^^^^^ numberSet.union(numberSetLike); >numberSet.union(numberSetLike) : Set +> : ^^^^^^^^ >numberSet.union : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >union : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ numberSet.intersection([]); >numberSet.intersection([]) : Set +> : ^^^^^^^^^^^ >numberSet.intersection : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >intersection : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >[] : undefined[] +> : ^^^^^^^^^^^ numberSet.intersection(new Set); >numberSet.intersection(new Set) : Set +> : ^^^^^^^^^^^ >numberSet.intersection : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >intersection : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >new Set : Set +> : ^^^^^^^^^^^^ >Set : SetConstructor +> : ^^^^^^^^^^^^^^ numberSet.intersection(stringSet); >numberSet.intersection(stringSet) : Set +> : ^^^^^^^^^^ >numberSet.intersection : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >intersection : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >stringSet : Set +> : ^^^^^^^^^^^ numberSet.intersection(numberMap); >numberSet.intersection(numberMap) : Set +> : ^^^^^^^^^^^ >numberSet.intersection : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >intersection : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberMap : Map +> : ^^^^^^^^^^^^^^^ numberSet.intersection(numberSetLike); >numberSet.intersection(numberSetLike) : Set +> : ^^^^^^^^ >numberSet.intersection : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >intersection : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ numberSet.difference([]); >numberSet.difference([]) : Set +> : ^^^^^^^^^^^ >numberSet.difference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >difference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >[] : undefined[] +> : ^^^^^^^^^^^ numberSet.difference(new Set); >numberSet.difference(new Set) : Set +> : ^^^^^^^^^^^ >numberSet.difference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >difference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >new Set : Set +> : ^^^^^^^^^^^^ >Set : SetConstructor +> : ^^^^^^^^^^^^^^ numberSet.difference(stringSet); >numberSet.difference(stringSet) : Set +> : ^^^^^^^^^^^ >numberSet.difference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >difference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >stringSet : Set +> : ^^^^^^^^^^^ numberSet.difference(numberMap); >numberSet.difference(numberMap) : Set +> : ^^^^^^^^^^^ >numberSet.difference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >difference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberMap : Map +> : ^^^^^^^^^^^^^^^ numberSet.difference(numberSetLike); >numberSet.difference(numberSetLike) : Set +> : ^^^^^^^^^^^ >numberSet.difference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >difference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ numberSet.symmetricDifference([]); >numberSet.symmetricDifference([]) : Set +> : ^^^^^^^^^^^^ >numberSet.symmetricDifference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >symmetricDifference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >[] : undefined[] +> : ^^^^^^^^^^^ numberSet.symmetricDifference(new Set); >numberSet.symmetricDifference(new Set) : Set +> : ^^^^^^^^^^^^ >numberSet.symmetricDifference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >symmetricDifference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >new Set : Set +> : ^^^^^^^^^^^^ >Set : SetConstructor +> : ^^^^^^^^^^^^^^ numberSet.symmetricDifference(stringSet); >numberSet.symmetricDifference(stringSet) : Set +> : ^^^^^^^^^^^^^^^^^^^^ >numberSet.symmetricDifference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >symmetricDifference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >stringSet : Set +> : ^^^^^^^^^^^ numberSet.symmetricDifference(numberMap); >numberSet.symmetricDifference(numberMap) : Set +> : ^^^^^^^^^^^ >numberSet.symmetricDifference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >symmetricDifference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberMap : Map +> : ^^^^^^^^^^^^^^^ numberSet.symmetricDifference(numberSetLike); >numberSet.symmetricDifference(numberSetLike) : Set +> : ^^^^^^^^ >numberSet.symmetricDifference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >symmetricDifference : (other: ReadonlySetLike) => Set +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ numberSet.isSubsetOf([]); >numberSet.isSubsetOf([]) : boolean +> : ^^^^^^^ >numberSet.isSubsetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isSubsetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >[] : undefined[] +> : ^^^^^^^^^^^ numberSet.isSubsetOf(new Set); >numberSet.isSubsetOf(new Set) : boolean +> : ^^^^^^^ >numberSet.isSubsetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isSubsetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >new Set : Set +> : ^^^^^^^^^^^^ >Set : SetConstructor +> : ^^^^^^^^^^^^^^ numberSet.isSubsetOf(stringSet); >numberSet.isSubsetOf(stringSet) : boolean +> : ^^^^^^^ >numberSet.isSubsetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isSubsetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >stringSet : Set +> : ^^^^^^^^^^^ numberSet.isSubsetOf(numberMap); >numberSet.isSubsetOf(numberMap) : boolean +> : ^^^^^^^ >numberSet.isSubsetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isSubsetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberMap : Map +> : ^^^^^^^^^^^^^^^ numberSet.isSubsetOf(numberSetLike); >numberSet.isSubsetOf(numberSetLike) : boolean +> : ^^^^^^^ >numberSet.isSubsetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isSubsetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ numberSet.isSupersetOf([]); >numberSet.isSupersetOf([]) : boolean +> : ^^^^^^^ >numberSet.isSupersetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isSupersetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >[] : undefined[] +> : ^^^^^^^^^^^ numberSet.isSupersetOf(new Set); >numberSet.isSupersetOf(new Set) : boolean +> : ^^^^^^^ >numberSet.isSupersetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isSupersetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >new Set : Set +> : ^^^^^^^^^^^^ >Set : SetConstructor +> : ^^^^^^^^^^^^^^ numberSet.isSupersetOf(stringSet); >numberSet.isSupersetOf(stringSet) : boolean +> : ^^^^^^^ >numberSet.isSupersetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isSupersetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >stringSet : Set +> : ^^^^^^^^^^^ numberSet.isSupersetOf(numberMap); >numberSet.isSupersetOf(numberMap) : boolean +> : ^^^^^^^ >numberSet.isSupersetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isSupersetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberMap : Map +> : ^^^^^^^^^^^^^^^ numberSet.isSupersetOf(numberSetLike); >numberSet.isSupersetOf(numberSetLike) : boolean +> : ^^^^^^^ >numberSet.isSupersetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isSupersetOf : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ numberSet.isDisjointFrom([]); >numberSet.isDisjointFrom([]) : boolean +> : ^^^^^^^ >numberSet.isDisjointFrom : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isDisjointFrom : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >[] : undefined[] +> : ^^^^^^^^^^^ numberSet.isDisjointFrom(new Set); >numberSet.isDisjointFrom(new Set) : boolean +> : ^^^^^^^ >numberSet.isDisjointFrom : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isDisjointFrom : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >new Set : Set +> : ^^^^^^^^^^^^ >Set : SetConstructor +> : ^^^^^^^^^^^^^^ numberSet.isDisjointFrom(stringSet); >numberSet.isDisjointFrom(stringSet) : boolean +> : ^^^^^^^ >numberSet.isDisjointFrom : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isDisjointFrom : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >stringSet : Set +> : ^^^^^^^^^^^ numberSet.isDisjointFrom(numberMap); >numberSet.isDisjointFrom(numberMap) : boolean +> : ^^^^^^^ >numberSet.isDisjointFrom : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isDisjointFrom : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberMap : Map +> : ^^^^^^^^^^^^^^^ numberSet.isDisjointFrom(numberSetLike); >numberSet.isDisjointFrom(numberSetLike) : boolean +> : ^^^^^^^ >numberSet.isDisjointFrom : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSet : Set +> : ^^^^^^^^^^^ >isDisjointFrom : (other: ReadonlySetLike) => boolean +> : ^ ^^ ^^^^^^^^^^^^ >numberSetLike : { size: number; keys(): Generator; has(x: any): boolean; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ From 41aea338621b3150c1838f20ec72f752150e0eed Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Thu, 16 May 2024 09:24:52 -0700 Subject: [PATCH 8/8] add new methods to ReadonlySet --- src/lib/esnext.collection.d.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/lib/esnext.collection.d.ts b/src/lib/esnext.collection.d.ts index 858aa0c965cbf..504ed6782d4bb 100644 --- a/src/lib/esnext.collection.d.ts +++ b/src/lib/esnext.collection.d.ts @@ -55,3 +55,34 @@ interface Set { */ isDisjointFrom(other: ReadonlySetLike): boolean; } + +interface ReadonlySet { + /** + * @returns a new Set containing all the elements in this Set and also all the elements in the argument. + */ + union(other: ReadonlySetLike): Set; + /** + * @returns a new Set containing all the elements which are both in this Set and in the argument. + */ + intersection(other: ReadonlySetLike): Set; + /** + * @returns a new Set containing all the elements in this Set which are not also in the argument. + */ + difference(other: ReadonlySetLike): Set; + /** + * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. + */ + symmetricDifference(other: ReadonlySetLike): Set; + /** + * @returns a boolean indicating whether all the elements in this Set are also in the argument. + */ + isSubsetOf(other: ReadonlySetLike): boolean; + /** + * @returns a boolean indicating whether all the elements in the argument are also in this Set. + */ + isSupersetOf(other: ReadonlySetLike): boolean; + /** + * @returns a boolean indicating whether this Set has no elements in common with the argument. + */ + isDisjointFrom(other: ReadonlySetLike): boolean; +}