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
6 changes: 3 additions & 3 deletions types/call-bind/test/callBind.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import callBind = require('call-bind');
import { apply as applyBind } from 'call-bind';

declare const any: unknown;
declare const unknown: unknown;

callBind(() => {}); // $ExpectType (thisArg: unknown) => void
callBind((a: string, b: number) => {}, null, 'foo'); // $ExpectType (b: number) => void

// $ExpectType (thisArg: unknown, v: string | number | symbol) => boolean || (thisArg: unknown, v: PropertyKey) => boolean
callBind(Object.prototype.hasOwnProperty);
// $ExpectType (v: string | number | symbol) => boolean || (v: PropertyKey) => boolean
callBind(Object.prototype.hasOwnProperty, any);
callBind(Object.prototype.hasOwnProperty, unknown);

applyBind(() => {}); // $ExpectType (thisArg: unknown, args: readonly []) => void
applyBind((a: string, b: number) => {}, null, 'foo'); // $ExpectType (args: readonly [b: number]) => void

// $ExpectType (thisArg: unknown, args: readonly [v: string | number | symbol]) => boolean || (thisArg: unknown, args: readonly [v: PropertyKey]) => boolean
applyBind(Object.prototype.hasOwnProperty);
// $ExpectType (args: readonly [v: string | number | symbol]) => boolean || (args: readonly [v: PropertyKey]) => boolean
applyBind(Object.prototype.hasOwnProperty, any);
applyBind(Object.prototype.hasOwnProperty, unknown);

// These are invalid because of `package.json#exports`:
import callBindIllegal1 = require('call-bind/index'); // $ExpectError
Expand Down
6 changes: 3 additions & 3 deletions types/call-bind/ts3.9/test/callBind.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import callBind = require('call-bind');
import { apply as applyBind } from 'call-bind';

declare const any: unknown;
declare const unknown: unknown;

callBind(() => {}); // $ExpectType (thisArg: unknown) => void
callBind((a: string, b: number) => {}, null, 'foo'); // $ExpectType (b: number) => void
callBind(Object.prototype.hasOwnProperty); // $ExpectType (thisArg: unknown, v: string | number | symbol) => boolean
callBind(Object.prototype.hasOwnProperty, any); // $ExpectType (v: string | number | symbol) => boolean
callBind(Object.prototype.hasOwnProperty, unknown); // $ExpectType (v: string | number | symbol) => boolean

applyBind(() => {}); // $ExpectType (thisArg: unknown, args: readonly []) => void
applyBind((a: string, b: number) => {}, null, 'foo'); // $ExpectType (args: readonly [number]) => void
applyBind(Object.prototype.hasOwnProperty); // $ExpectType (thisArg: unknown, args: readonly [string | number | symbol]) => boolean
applyBind(Object.prototype.hasOwnProperty, any); // $ExpectType (args: readonly [string | number | symbol]) => boolean
applyBind(Object.prototype.hasOwnProperty, unknown); // $ExpectType (args: readonly [string | number | symbol]) => boolean
2 changes: 1 addition & 1 deletion types/es-abstract/test/es2015.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ES2015.GetIterator(null, generable);
ES2015.IteratorNext(generable()); // $ExpectType IteratorResult<number, boolean>
ES2015.IteratorNext(any as AsyncGenerator<number, void>); // $ExpectType Promise<IteratorResult<number, void>>

// $ExpectType IteratorYieldResult<number> | IteratorReturnResult<void> | Promise<IteratorResult<number, void>>
// $ExpectType IteratorYieldResult<number> | IteratorReturnResult<void> | Promise<IteratorResult<number, void>> || IteratorResult<number, void> | Promise<IteratorResult<number, void>>
expectType<IteratorResult<number, void> | Promise<IteratorResult<number, void>>>(
ES2015.IteratorNext<number, void>(any as Generator<number, void> | AsyncGenerator<number, void>),
);
Expand Down
19 changes: 13 additions & 6 deletions types/es-abstract/test/helpers/callBind.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import callBind = require('es-abstract/helpers/callBind');
import { apply as applyBind } from 'es-abstract/helpers/callBind';

declare const any: unknown;
declare const unknown: unknown;

callBind(() => {}); // $ExpectType (thisArg: unknown) => void
callBind(Object.prototype.hasOwnProperty); // $ExpectType (thisArg: unknown, v: string | number | symbol) => boolean
callBind(Object.prototype.hasOwnProperty, any); // $ExpectType (v: string | number | symbol) => boolean
callBind((a: string, b: number) => {}, null, 'foo'); // $ExpectType (b: number) => void

// $ExpectType (thisArg: unknown, v: string | number | symbol) => boolean || (thisArg: unknown, v: PropertyKey) => boolean
callBind(Object.prototype.hasOwnProperty);
// $ExpectType (v: string | number | symbol) => boolean || (v: PropertyKey) => boolean
callBind(Object.prototype.hasOwnProperty, unknown);

applyBind(() => {}); // $ExpectType (thisArg: unknown, args: readonly []) => void
// $ExpectType (thisArg: unknown, args: readonly [string | number | symbol]) => boolean || (thisArg: unknown, args: readonly [v: string | number | symbol]) => boolean
applyBind((a: string, b: number) => {}, null, 'foo'); // $ExpectType (args: readonly [number]) => void || (args: readonly [b: number]) => void

// tslint:disable-next-line: max-line-length
// $ExpectType (thisArg: unknown, args: readonly [string | number | symbol]) => boolean || (thisArg: unknown, args: readonly [v: string | number | symbol]) => boolean || (thisArg: unknown, args: readonly [v: PropertyKey]) => boolean
applyBind(Object.prototype.hasOwnProperty);
// $ExpectType (args: readonly [string | number | symbol]) => boolean || (args: readonly [v: string | number | symbol]) => boolean
applyBind(Object.prototype.hasOwnProperty, any);
// $ExpectType (args: readonly [string | number | symbol]) => boolean || (args: readonly [v: string | number | symbol]) => boolean || (args: readonly [v: PropertyKey]) => boolean
applyBind(Object.prototype.hasOwnProperty, unknown);
7 changes: 4 additions & 3 deletions types/es-abstract/test/helpers/callBound.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ callBound('%ArrayProto_forEach%'); // $ExpectType (thisArg: unknown, callbackfn:
callBound('%ObjProto_toString%'); // $ExpectType (thisArg: unknown) => string
callBound('%ObjProto_valueOf%'); // $ExpectType (thisArg: unknown) => Object

// tslint:disable-next-line: max-line-length
callBound('%PromiseProto_then%'); // $ExpectType (thisArg: unknown, onfulfilled?: ((value: any) => unknown) | null | undefined, onrejected?: ((reason: any) => unknown) | null | undefined) => Promise<unknown>
// $ExpectType (thisArg: unknown, onfulfilled?: ((value: any) => unknown) | null | undefined, onrejected?: ((reason: any) => unknown) | null | undefined) => Promise<unknown>
callBound('%PromiseProto_then%');

// Dotted intrinsic:
callBound('%Object.prototype.hasOwnProperty%'); // $ExpectType (thisArg: unknown, v: string | number | symbol) => boolean
// $ExpectType (thisArg: unknown, v: string | number | symbol) => boolean || (thisArg: unknown, v: PropertyKey) => boolean
callBound('%Object.prototype.hasOwnProperty%');
5 changes: 3 additions & 2 deletions types/es-abstract/test/helpers/getIteratorMethod.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import getIteratorMethod = require('es-abstract/helpers/getIteratorMethod');
import ES5 = require('es-abstract/es5');
import ES2015 = require('es-abstract/es2015');

declare const any: unknown;
declare const unknown: unknown;
declare const never: never;

getIteratorMethod(ES2015, [1]); // $ExpectType () => Iterator<number, any, any>
Expand All @@ -12,7 +12,8 @@ getIteratorMethod(ES2015, '2'); // $ExpectType () => Iterator<string, any, any>

getIteratorMethod(ES2015, undefined); // $ExpectType undefined
getIteratorMethod(ES2015, {}); // $ExpectType undefined
getIteratorMethod<any>(ES2015, any); // $ExpectType (() => Iterator<any, any, any>) | undefined
// $ExpectType (() => Iterator<any, any, any>) | undefined || (() => Iterator<unknown, any, any>) | undefined
getIteratorMethod<any>(ES2015, unknown);
getIteratorMethod(ES2015, never); // $ExpectType never

// $ExpectError
Expand Down
8 changes: 4 additions & 4 deletions types/es-abstract/test/helpers/isPropertyDescriptor.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import ES5 = require('es-abstract/es5');
import isPropertyDescriptor = require('es-abstract/helpers/isPropertyDescriptor');

declare const any: unknown;
declare const unknown: unknown;
declare const optPropDesc: ES5.PropertyDescriptor<string> | null;

if (isPropertyDescriptor(ES5, any)) {
any; // $ExpectType PropertyDescriptor<unknown>
if (isPropertyDescriptor(ES5, unknown)) {
unknown; // $ExpectType PropertyDescriptor<unknown>
}

if (isPropertyDescriptor(ES5, optPropDesc)) {
optPropDesc; // $ExpectType PropertyDescriptor<string>
optPropDesc; // $ExpectType PropertyDescriptor<string> || AccessorDescriptor<string> | DataDescriptor<string>
}