diff --git a/src/lib/esnext.collection.d.ts b/src/lib/esnext.collection.d.ts index 7a799f3c494e7..504ed6782d4bb 100644 --- a/src/lib/esnext.collection.d.ts +++ b/src/lib/esnext.collection.d.ts @@ -9,3 +9,80 @@ interface MapConstructor { keySelector: (item: T, index: number) => K, ): Map; } + +interface ReadonlySetLike { + /** + * Despite its name, returns an iterator of the values in the set-like. + */ + keys(): Iterator; + /** + * @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: 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; +} + +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; +} 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/setMethods.errors.txt b/tests/baselines/reference/setMethods.errors.txt new file mode 100644 index 0000000000000..dc46f007ec67f --- /dev/null +++ b/tests/baselines/reference/setMethods.errors.txt @@ -0,0 +1,80 @@ +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 (7 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 'ReadonlySetLike'. +!!! error TS2345: Type 'undefined[]' is missing the following properties from type 'ReadonlySetLike': has, size + numberSet.union(new Set); + numberSet.union(stringSet); + numberSet.union(numberMap); + numberSet.union(numberSetLike); + + numberSet.intersection([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. + numberSet.intersection(new Set); + numberSet.intersection(stringSet); + numberSet.intersection(numberMap); + numberSet.intersection(numberSetLike); + + numberSet.difference([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. + numberSet.difference(new Set); + numberSet.difference(stringSet); + numberSet.difference(numberMap); + numberSet.difference(numberSetLike); + + numberSet.symmetricDifference([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. + numberSet.symmetricDifference(new Set); + numberSet.symmetricDifference(stringSet); + numberSet.symmetricDifference(numberMap); + numberSet.symmetricDifference(numberSetLike); + + numberSet.isSubsetOf([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. + numberSet.isSubsetOf(new Set); + numberSet.isSubsetOf(stringSet); + numberSet.isSubsetOf(numberMap); + numberSet.isSubsetOf(numberSetLike); + + numberSet.isSupersetOf([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. + numberSet.isSupersetOf(new Set); + numberSet.isSupersetOf(stringSet); + numberSet.isSupersetOf(numberMap); + numberSet.isSupersetOf(numberSetLike); + + numberSet.isDisjointFrom([]); + ~~ +!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'ReadonlySetLike'. + numberSet.isDisjointFrom(new Set); + numberSet.isDisjointFrom(stringSet); + 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..3a1d6dd950915 --- /dev/null +++ b/tests/baselines/reference/setMethods.types @@ -0,0 +1,523 @@ +//// [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: 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; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ + 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)) 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);