Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/bresenham/bresenham-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ bresenham(0, 0, 10, 12);
bresenham(0, 0, 10, 12, (x: number, y: number) => {
});

// $ExpectType Generator<Point, any, unknown>
// $ExpectType Generator<Point, any, unknown> || Generator<Point, any, any>
generatorFn(0, 0, 10, 12);
6 changes: 3 additions & 3 deletions types/call-bind/test/callBound.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import callBound = require("call-bind/callBound");

callBound("%ArrayProto_keys%"); // $ExpectType (thisArg: unknown) => IterableIterator<number>
callBound("%ArrayProto_values%"); // $ExpectType (thisArg: unknown) => IterableIterator<any>
callBound("%ArrayProto_entries%"); // $ExpectType (thisArg: unknown) => IterableIterator<[number, any]>
callBound("%ArrayProto_keys%"); // $ExpectType (thisArg: unknown) => IterableIterator<number> || (thisArg: unknown) => BuiltinIterator<number, any, any>
callBound("%ArrayProto_values%"); // $ExpectType (thisArg: unknown) => IterableIterator<any> || (thisArg: unknown) => BuiltinIterator<any, any, any>
callBound("%ArrayProto_entries%"); // $ExpectType (thisArg: unknown) => IterableIterator<[number, any]> || (thisArg: unknown) => BuiltinIterator<[number, any], any, any>
callBound("%ArrayProto_forEach%"); // $ExpectType (thisArg: unknown, callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any) => void

callBound("%ObjProto_toString%"); // $ExpectType (thisArg: unknown) => string
Expand Down
24 changes: 12 additions & 12 deletions types/es-abstract/test/GetIntrinsic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ declare const boolean: boolean;
GetIntrinsic("%ArrayBufferPrototype%"); // $ExpectType ArrayBuffer

GetIntrinsic("%ArrayIteratorPrototype%"); // $ExpectType IterableIterator<any>
GetIntrinsic("%AsyncFromSyncIteratorPrototype%"); // $ExpectType AsyncGenerator<any, any, unknown>
GetIntrinsic("%AsyncFromSyncIteratorPrototype%"); // $ExpectType AsyncGenerator<any, any, unknown> || AsyncGenerator<any, any, any>

GetIntrinsic("%AsyncFunction%"); // $ExpectType FunctionConstructor
GetIntrinsic("%AsyncFunction.prototype%"); // $ExpectType Function
GetIntrinsic("%AsyncFunctionPrototype%"); // $ExpectType Function

GetIntrinsic("%AsyncGenerator%"); // $ExpectType AsyncGeneratorFunction
GetIntrinsic("%AsyncGeneratorFunction%"); // $ExpectType AsyncGeneratorFunctionConstructor
GetIntrinsic("%AsyncGeneratorPrototype%"); // $ExpectType AsyncGenerator<any, any, unknown>
GetIntrinsic("%AsyncGeneratorPrototype%"); // $ExpectType AsyncGenerator<any, any, unknown> || AsyncGenerator<any, any, any>
GetIntrinsic("%AsyncIteratorPrototype%"); // $ExpectType AsyncIterable<any>

GetIntrinsic("%Atomics%"); // $ExpectType Atomics
Expand Down Expand Up @@ -78,7 +78,7 @@ declare const boolean: boolean;

GetIntrinsic("%Generator%"); // $ExpectType GeneratorFunction
GetIntrinsic("%GeneratorFunction%"); // $ExpectType GeneratorFunctionConstructor
GetIntrinsic("%GeneratorPrototype%"); // $ExpectType Generator<any, any, unknown>
GetIntrinsic("%GeneratorPrototype%"); // $ExpectType Generator<any, any, unknown> || Generator<any, any, any>
GetIntrinsic("%IteratorPrototype%"); // $ExpectType Iterable<any>

GetIntrinsic("%Int8Array%"); // $ExpectType Int8ArrayConstructor
Expand Down Expand Up @@ -232,15 +232,15 @@ declare const boolean: boolean;
GetIntrinsic("%ArrayBufferPrototype%", false); // $ExpectType ArrayBuffer

GetIntrinsic("%ArrayIteratorPrototype%", false); // $ExpectType IterableIterator<any>
GetIntrinsic("%AsyncFromSyncIteratorPrototype%", false); // $ExpectType AsyncGenerator<any, any, unknown>
GetIntrinsic("%AsyncFromSyncIteratorPrototype%", false); // $ExpectType AsyncGenerator<any, any, unknown> || AsyncGenerator<any, any, any>

GetIntrinsic("%AsyncFunction%", false); // $ExpectType FunctionConstructor
GetIntrinsic("%AsyncFunction.prototype%", false); // $ExpectType Function
GetIntrinsic("%AsyncFunctionPrototype%", false); // $ExpectType Function

GetIntrinsic("%AsyncGenerator%", false); // $ExpectType AsyncGeneratorFunction
GetIntrinsic("%AsyncGeneratorFunction%", false); // $ExpectType AsyncGeneratorFunctionConstructor
GetIntrinsic("%AsyncGeneratorPrototype%", false); // $ExpectType AsyncGenerator<any, any, unknown>
GetIntrinsic("%AsyncGeneratorPrototype%", false); // $ExpectType AsyncGenerator<any, any, unknown> || AsyncGenerator<any, any, any>
GetIntrinsic("%AsyncIteratorPrototype%", false); // $ExpectType AsyncIterable<any>

GetIntrinsic("%Atomics%", false); // $ExpectType Atomics
Expand Down Expand Up @@ -287,7 +287,7 @@ declare const boolean: boolean;

GetIntrinsic("%Generator%", false); // $ExpectType GeneratorFunction
GetIntrinsic("%GeneratorFunction%", false); // $ExpectType GeneratorFunctionConstructor
GetIntrinsic("%GeneratorPrototype%", false); // $ExpectType Generator<any, any, unknown>
GetIntrinsic("%GeneratorPrototype%", false); // $ExpectType Generator<any, any, unknown> || Generator<any, any, any>
GetIntrinsic("%IteratorPrototype%", false); // $ExpectType Iterable<any>

GetIntrinsic("%Int8Array%", false); // $ExpectType Int8ArrayConstructor
Expand Down Expand Up @@ -441,15 +441,15 @@ declare const boolean: boolean;
GetIntrinsic("%ArrayBufferPrototype%", true); // $ExpectType ArrayBuffer | undefined

GetIntrinsic("%ArrayIteratorPrototype%", true); // $ExpectType IterableIterator<any> | undefined
GetIntrinsic("%AsyncFromSyncIteratorPrototype%", true); // $ExpectType AsyncGenerator<any, any, unknown> | undefined
GetIntrinsic("%AsyncFromSyncIteratorPrototype%", true); // $ExpectType AsyncGenerator<any, any, unknown> | undefined || AsyncGenerator<any, any, any> | undefined

GetIntrinsic("%AsyncFunction%", true); // $ExpectType FunctionConstructor | undefined
GetIntrinsic("%AsyncFunction.prototype%", true); // $ExpectType Function | undefined
GetIntrinsic("%AsyncFunctionPrototype%", true); // $ExpectType Function | undefined

GetIntrinsic("%AsyncGenerator%", true); // $ExpectType AsyncGeneratorFunction | undefined
GetIntrinsic("%AsyncGeneratorFunction%", true); // $ExpectType AsyncGeneratorFunctionConstructor | undefined
GetIntrinsic("%AsyncGeneratorPrototype%", true); // $ExpectType AsyncGenerator<any, any, unknown> | undefined
GetIntrinsic("%AsyncGeneratorPrototype%", true); // $ExpectType AsyncGenerator<any, any, unknown> | undefined || AsyncGenerator<any, any, any> | undefined
GetIntrinsic("%AsyncIteratorPrototype%", true); // $ExpectType AsyncIterable<any> | undefined

GetIntrinsic("%Atomics%", true); // $ExpectType Atomics | undefined
Expand Down Expand Up @@ -496,7 +496,7 @@ declare const boolean: boolean;

GetIntrinsic("%Generator%", true); // $ExpectType GeneratorFunction | undefined
GetIntrinsic("%GeneratorFunction%", true); // $ExpectType GeneratorFunctionConstructor | undefined
GetIntrinsic("%GeneratorPrototype%", true); // $ExpectType Generator<any, any, unknown> | undefined
GetIntrinsic("%GeneratorPrototype%", true); // $ExpectType Generator<any, any, unknown> | undefined || Generator<any, any, any> | undefined
GetIntrinsic("%IteratorPrototype%", true); // $ExpectType Iterable<any> | undefined

GetIntrinsic("%Int8Array%", true); // $ExpectType Int8ArrayConstructor | undefined
Expand Down Expand Up @@ -650,15 +650,15 @@ declare const boolean: boolean;
GetIntrinsic("%ArrayBufferPrototype%", boolean); // $ExpectType ArrayBuffer | undefined

GetIntrinsic("%ArrayIteratorPrototype%", boolean); // $ExpectType IterableIterator<any> | undefined
GetIntrinsic("%AsyncFromSyncIteratorPrototype%", boolean); // $ExpectType AsyncGenerator<any, any, unknown> | undefined
GetIntrinsic("%AsyncFromSyncIteratorPrototype%", boolean); // $ExpectType AsyncGenerator<any, any, unknown> | undefined || AsyncGenerator<any, any, any> | undefined

GetIntrinsic("%AsyncFunction%", boolean); // $ExpectType FunctionConstructor | undefined
GetIntrinsic("%AsyncFunction.prototype%", boolean); // $ExpectType Function | undefined
GetIntrinsic("%AsyncFunctionPrototype%", boolean); // $ExpectType Function | undefined

GetIntrinsic("%AsyncGenerator%", boolean); // $ExpectType AsyncGeneratorFunction | undefined
GetIntrinsic("%AsyncGeneratorFunction%", boolean); // $ExpectType AsyncGeneratorFunctionConstructor | undefined
GetIntrinsic("%AsyncGeneratorPrototype%", boolean); // $ExpectType AsyncGenerator<any, any, unknown> | undefined
GetIntrinsic("%AsyncGeneratorPrototype%", boolean); // $ExpectType AsyncGenerator<any, any, unknown> | undefined || AsyncGenerator<any, any, any> | undefined
GetIntrinsic("%AsyncIteratorPrototype%", boolean); // $ExpectType AsyncIterable<any> | undefined

GetIntrinsic("%Atomics%", boolean); // $ExpectType Atomics | undefined
Expand Down Expand Up @@ -705,7 +705,7 @@ declare const boolean: boolean;

GetIntrinsic("%Generator%", boolean); // $ExpectType GeneratorFunction | undefined
GetIntrinsic("%GeneratorFunction%", boolean); // $ExpectType GeneratorFunctionConstructor | undefined
GetIntrinsic("%GeneratorPrototype%", boolean); // $ExpectType Generator<any, any, unknown> | undefined
GetIntrinsic("%GeneratorPrototype%", boolean); // $ExpectType Generator<any, any, unknown> | undefined || Generator<any, any, any> | undefined
GetIntrinsic("%IteratorPrototype%", boolean); // $ExpectType Iterable<any> | undefined

GetIntrinsic("%Int8Array%", boolean); // $ExpectType Int8ArrayConstructor | undefined
Expand Down
4 changes: 2 additions & 2 deletions types/es-abstract/test/es2015.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ES2015.Call<bigint, readonly [], string>(Object.prototype.toString, BigInt(Numbe
ES2015.Call(Object.prototype.hasOwnProperty, [], ["length"] as const); // $ExpectType boolean
ES2015.Call(Object.prototype.hasOwnProperty, any, args as IArguments & [PropertyKey]); // $ExpectType boolean

// $ExpectType IterableIterator<number>
// $ExpectType IterableIterator<number> || BuiltinIterator<number, any, any>
ES2015.GetIterator([1, 2, 3]);

function* generable() {
Expand Down Expand Up @@ -103,7 +103,7 @@ if (ES2015.IteratorComplete(iteratorResult)) {

const anyIterator = any as Iterator<unknown, unknown, unknown>;

ES2015.GetMethod(anyIterator, "next"); // $ExpectType (...args: [] | [unknown]) => IteratorResult<unknown, unknown>
ES2015.GetMethod(anyIterator, "next"); // $ExpectType (...args: [] | [unknown]) => IteratorResult<unknown, unknown> || (...[value]: [] | [unknown]) => IteratorResult<unknown, unknown>
ES2015.GetMethod(anyIterator, "throw"); // $ExpectType ((e?: any) => IteratorResult<unknown, unknown>) | undefined
ES2015.GetMethod(anyIterator, "return"); // $ExpectType ((value?: unknown) => IteratorResult<unknown, unknown>) | undefined

Expand Down
6 changes: 3 additions & 3 deletions types/es-abstract/test/helpers/callBound.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import callBound = require("es-abstract/helpers/callBound");

callBound("%ArrayProto_keys%"); // $ExpectType (thisArg: unknown) => IterableIterator<number>
callBound("%ArrayProto_values%"); // $ExpectType (thisArg: unknown) => IterableIterator<any>
callBound("%ArrayProto_entries%"); // $ExpectType (thisArg: unknown) => IterableIterator<[number, any]>
callBound("%ArrayProto_keys%"); // $ExpectType (thisArg: unknown) => IterableIterator<number> || (thisArg: unknown) => BuiltinIterator<number, any, any>
callBound("%ArrayProto_values%"); // $ExpectType (thisArg: unknown) => IterableIterator<any> || (thisArg: unknown) => BuiltinIterator<any, any, any>
callBound("%ArrayProto_entries%"); // $ExpectType (thisArg: unknown) => IterableIterator<[number, any]> || (thisArg: unknown) => BuiltinIterator<[number, any], any, any>
callBound("%ArrayProto_forEach%"); // $ExpectType (thisArg: unknown, callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any) => void

callBound("%ObjProto_toString%"); // $ExpectType (thisArg: unknown) => string
Expand Down
20 changes: 10 additions & 10 deletions types/es-get-iterator/es-get-iterator-tests.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import getIterator = require("es-get-iterator");

// $ExpectType Iterator<string, any, undefined>
// $ExpectType Iterator<string, any, undefined> || Iterator<string, any, any>
getIterator("foo");

// $ExpectType Iterator<never, any, undefined>
// $ExpectType Iterator<never, any, undefined> || Iterator<never, any, any>
getIterator([]);

// $ExpectType Iterator<number, any, undefined>
// $ExpectType Iterator<number, any, undefined> || Iterator<number, any, any>
getIterator([0, 1, 2, 3, 4]);

// $ExpectType Iterator<string | number | boolean | undefined, any, undefined>
// $ExpectType Iterator<string | number | boolean | undefined, any, undefined> || Iterator<string | number | boolean | undefined, any, any>
getIterator([undefined, true, "bar", 0]);

// $ExpectType Iterator<[symbol, unknown], any, undefined>
// $ExpectType Iterator<[symbol, unknown], any, undefined> || Iterator<[symbol, unknown], any, any>
getIterator(new Map<symbol, unknown>());

// $ExpectType Iterator<boolean, any, undefined>
// $ExpectType Iterator<boolean, any, undefined> || Iterator<boolean, any, any>
getIterator(new Set<boolean>());

// $ExpectType Iterator<"foo" | "bar", void, unknown> || Iterator<"foo" | "bar", void, any>
Expand All @@ -32,19 +32,19 @@ getIterator((function*() {
})());

declare const ARGUMENTS: IArguments;
// $ExpectType Iterator<any, any, undefined>
// $ExpectType Iterator<any, any, undefined> || Iterator<any, any, any>
getIterator(ARGUMENTS);

declare const ITERABLE_UNION: number[] | Set<Date>;
// $ExpectType Iterator<number, any, undefined> | Iterator<Date, any, undefined>
// $ExpectType Iterator<number, any, undefined> | Iterator<Date, any, undefined> || Iterator<number, any, any> | Iterator<Date, any, any>
getIterator(ITERABLE_UNION);

declare const ITERABLE_OR_OTHERS_UNION: Map<Error, DataView> | ArrayBuffer;
// $ExpectType Iterator<[Error, DataView], any, undefined> | undefined
// $ExpectType Iterator<[Error, DataView], any, undefined> | undefined || Iterator<[Error, DataView], any, any> | undefined
getIterator(ITERABLE_OR_OTHERS_UNION);

declare const UNKNOWN: unknown;
// $ExpectType Iterator<unknown, any, undefined> | undefined
// $ExpectType Iterator<unknown, any, undefined> | undefined || Iterator<unknown, any, any> | undefined
getIterator(UNKNOWN);

// $ExpectType undefined
Expand Down
4 changes: 2 additions & 2 deletions types/es-get-iterator/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
interface Iterable<T, TReturn = unknown, TNext = undefined> {
interface Iterable<T, TReturn = any, TNext = any> {
[Symbol.iterator](): Iterator<T, TReturn, TNext>;
}

type InferIterable<T> = T extends Iterable<infer TYield, infer TReturn, infer TNext> ? Iterator<TYield, TReturn, TNext>
: unknown extends T ? Iterator<unknown> | undefined
: unknown extends T ? Iterator<unknown, any, any> | undefined
: undefined;

declare function getIterator<T>(iterable: T): InferIterable<T>;
Expand Down
Loading