Merge pull request #27028 from Microsoft/typedBindCallApply

Strict bind, call, and apply methods on functions
This commit is contained in:
Anders Hejlsberg 2018-09-24 18:20:05 -07:00 committed by GitHub
commit e36957aba1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 1280 additions and 81 deletions

View file

@ -77,6 +77,7 @@ namespace ts {
const allowSyntheticDefaultImports = getAllowSyntheticDefaultImports(compilerOptions);
const strictNullChecks = getStrictOptionValue(compilerOptions, "strictNullChecks");
const strictFunctionTypes = getStrictOptionValue(compilerOptions, "strictFunctionTypes");
const strictBindCallApply = getStrictOptionValue(compilerOptions, "strictBindCallApply");
const strictPropertyInitialization = getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
const noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
const noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
@ -476,6 +477,8 @@ namespace ts {
let globalObjectType: ObjectType;
let globalFunctionType: ObjectType;
let globalCallableFunctionType: ObjectType;
let globalNewableFunctionType: ObjectType;
let globalArrayType: GenericType;
let globalReadonlyArrayType: GenericType;
let globalStringType: ObjectType;
@ -7391,8 +7394,12 @@ namespace ts {
if (symbol && symbolIsValue(symbol)) {
return symbol;
}
if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
const symbol = getPropertyOfObjectType(globalFunctionType, name);
const functionType = resolved === anyFunctionType ? globalFunctionType :
resolved.callSignatures.length ? globalCallableFunctionType :
resolved.constructSignatures.length ? globalNewableFunctionType :
undefined;
if (functionType) {
const symbol = getPropertyOfObjectType(functionType, name);
if (symbol) {
return symbol;
}
@ -13250,10 +13257,8 @@ namespace ts {
const targetCount = getParameterCount(target);
const sourceRestType = getEffectiveRestType(source);
const targetRestType = getEffectiveRestType(target);
const paramCount = targetRestType ? Math.min(targetCount - 1, sourceCount) :
sourceRestType ? targetCount :
Math.min(sourceCount, targetCount);
const targetNonRestCount = targetRestType ? targetCount - 1 : targetCount;
const paramCount = sourceRestType ? targetNonRestCount : Math.min(sourceCount, targetNonRestCount);
const sourceThisType = getThisTypeOfSignature(source);
if (sourceThisType) {
const targetThisType = getThisTypeOfSignature(target);
@ -13900,15 +13905,17 @@ namespace ts {
if (!inferredType) {
const signature = context.signature;
if (signature) {
if (inference.contraCandidates && (!inference.candidates || inference.candidates.length === 1 && inference.candidates[0].flags & TypeFlags.Never)) {
// If we have contravariant inferences, but no covariant inferences or a single
// covariant inference of 'never', we find the best common subtype and treat that
// as a single covariant candidate.
inference.candidates = [getContravariantInference(inference)];
inference.contraCandidates = undefined;
const inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined;
if (inference.contraCandidates) {
const inferredContravariantType = getContravariantInference(inference);
// If we have both co- and contra-variant inferences, we prefer the contra-variant inference
// unless the co-variant inference is a subtype and not 'never'.
inferredType = inferredCovariantType && !(inferredCovariantType.flags & TypeFlags.Never) &&
isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ?
inferredCovariantType : inferredContravariantType;
}
if (inference.candidates) {
inferredType = getCovariantInference(inference, signature);
else if (inferredCovariantType) {
inferredType = inferredCovariantType;
}
else if (context.flags & InferenceFlags.NoDefault) {
// We use silentNeverType as the wildcard that signals no inferences.
@ -19695,7 +19702,10 @@ namespace ts {
checkCandidate = candidate;
}
if (!checkApplicableSignature(node, args, checkCandidate, relation, excludeArgument, /*reportErrors*/ false)) {
candidateForArgumentError = checkCandidate;
// Give preference to error candidates that have no rest parameters (as they are more specific)
if (!candidateForArgumentError || getEffectiveRestType(candidateForArgumentError) || !getEffectiveRestType(checkCandidate)) {
candidateForArgumentError = checkCandidate;
}
continue;
}
if (excludeArgument) {
@ -19708,7 +19718,10 @@ namespace ts {
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration));
}
if (!checkApplicableSignature(node, args, checkCandidate, relation, excludeArgument, /*reportErrors*/ false)) {
candidateForArgumentError = checkCandidate;
// Give preference to error candidates that have no rest parameters (as they are more specific)
if (!candidateForArgumentError || getEffectiveRestType(candidateForArgumentError) || !getEffectiveRestType(checkCandidate)) {
candidateForArgumentError = checkCandidate;
}
continue;
}
}
@ -28040,8 +28053,11 @@ namespace ts {
function getAugmentedPropertiesOfType(type: Type): Symbol[] {
type = getApparentType(type);
const propsByName = createSymbolTable(getPropertiesOfType(type));
if (typeHasCallOrConstructSignatures(type)) {
forEach(getPropertiesOfType(globalFunctionType), p => {
const functionType = getSignaturesOfType(type, SignatureKind.Call).length ? globalCallableFunctionType :
getSignaturesOfType(type, SignatureKind.Construct).length ? globalNewableFunctionType :
undefined;
if (functionType) {
forEach(getPropertiesOfType(functionType), p => {
if (!propsByName.has(p.escapedName)) {
propsByName.set(p.escapedName, p);
}
@ -28821,6 +28837,8 @@ namespace ts {
globalArrayType = getGlobalType("Array" as __String, /*arity*/ 1, /*reportErrors*/ true);
globalObjectType = getGlobalType("Object" as __String, /*arity*/ 0, /*reportErrors*/ true);
globalFunctionType = getGlobalType("Function" as __String, /*arity*/ 0, /*reportErrors*/ true);
globalCallableFunctionType = strictBindCallApply && getGlobalType("CallableFunction" as __String, /*arity*/ 0, /*reportErrors*/ true) || globalFunctionType;
globalNewableFunctionType = strictBindCallApply && getGlobalType("NewableFunction" as __String, /*arity*/ 0, /*reportErrors*/ true) || globalFunctionType;
globalStringType = getGlobalType("String" as __String, /*arity*/ 0, /*reportErrors*/ true);
globalNumberType = getGlobalType("Number" as __String, /*arity*/ 0, /*reportErrors*/ true);
globalBooleanType = getGlobalType("Boolean" as __String, /*arity*/ 0, /*reportErrors*/ true);

View file

@ -373,6 +373,14 @@ namespace ts {
category: Diagnostics.Strict_Type_Checking_Options,
description: Diagnostics.Enable_strict_checking_of_function_types
},
{
name: "strictBindCallApply",
type: "boolean",
strictFlag: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Strict_Type_Checking_Options,
description: Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions
},
{
name: "strictPropertyInitialization",
type: "boolean",

View file

@ -3759,6 +3759,10 @@
"category": "Message",
"code": 6213
},
"Enable strict 'bind', 'call', and 'apply' methods on functions.": {
"category": "Message",
"code": 6214
},
"Projects to reference": {
"category": "Message",

View file

@ -4427,6 +4427,7 @@ namespace ts {
sourceRoot?: string;
strict?: boolean;
strictFunctionTypes?: boolean; // Always combine with strict property
strictBindCallApply?: boolean; // Always combine with strict property
strictNullChecks?: boolean; // Always combine with strict property
strictPropertyInitialization?: boolean; // Always combine with strict property
stripInternal?: boolean;

View file

@ -7085,7 +7085,7 @@ namespace ts {
return !!(compilerOptions.declaration || compilerOptions.composite);
}
export type StrictOptionName = "noImplicitAny" | "noImplicitThis" | "strictNullChecks" | "strictFunctionTypes" | "strictPropertyInitialization" | "alwaysStrict";
export type StrictOptionName = "noImplicitAny" | "noImplicitThis" | "strictNullChecks" | "strictFunctionTypes" | "strictBindCallApply" | "strictPropertyInitialization" | "alwaysStrict";
export function getStrictOptionValue(compilerOptions: CompilerOptions, flag: StrictOptionName): boolean {
return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag];

View file

@ -4,6 +4,8 @@ namespace ts.TestFSWithWatch {
content: `/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}

60
src/lib/es5.d.ts vendored
View file

@ -295,6 +295,66 @@ interface FunctionConstructor {
declare const Function: FunctionConstructor;
interface CallableFunction extends Function {
/**
* Calls the function with the specified object as the this value and the elements of specified array as the arguments.
* @param thisArg The object to be used as the this object.
* @param args An array of argument values to be passed to the function.
*/
apply<T, R>(this: (this: T) => R, thisArg: T): R;
apply<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R;
/**
* Calls the function with the specified object as the this value and the specified rest arguments as the arguments.
* @param thisArg The object to be used as the this object.
* @param args Argument values to be passed to the function.
*/
call<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A): R;
/**
* For a given function, creates a bound function that has the same body as the original function.
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
* @param thisArg The object to be used as the this object.
* @param args Arguments to bind to the parameters of the function.
*/
bind<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R;
bind<T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R;
bind<T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R;
bind<T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R;
bind<T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R;
bind<T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R;
}
interface NewableFunction extends Function {
/**
* Calls the function with the specified object as the this value and the elements of specified array as the arguments.
* @param thisArg The object to be used as the this object.
* @param args An array of argument values to be passed to the function.
*/
apply<T>(this: new () => T, thisArg: T): void;
apply<T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void;
/**
* Calls the function with the specified object as the this value and the specified rest arguments as the arguments.
* @param thisArg The object to be used as the this object.
* @param args Argument values to be passed to the function.
*/
call<T, A extends any[]>(this: new (...args: A) => T, thisArg: T, ...args: A): void;
/**
* For a given function, creates a bound function that has the same body as the original function.
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
* @param thisArg The object to be used as the this object.
* @param args Arguments to bind to the parameters of the function.
*/
bind<A extends any[], R>(this: new (...args: A) => R, thisArg: any): new (...args: A) => R;
bind<A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R;
bind<A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R;
bind<A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R;
bind<A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R;
bind<AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R;
}
interface IArguments {
[index: number]: any;
length: number;

View file

@ -2494,6 +2494,7 @@ declare namespace ts {
sourceRoot?: string;
strict?: boolean;
strictFunctionTypes?: boolean;
strictBindCallApply?: boolean;
strictNullChecks?: boolean;
strictPropertyInitialization?: boolean;
stripInternal?: boolean;

View file

@ -2494,6 +2494,7 @@ declare namespace ts {
sourceRoot?: string;
strict?: boolean;
strictFunctionTypes?: boolean;
strictBindCallApply?: boolean;
strictNullChecks?: boolean;
strictPropertyInitialization?: boolean;
stripInternal?: boolean;

View file

@ -0,0 +1,31 @@
error TS2318: Cannot find global type 'CallableFunction'.
error TS2318: Cannot find global type 'NewableFunction'.
!!! error TS2318: Cannot find global type 'CallableFunction'.
!!! error TS2318: Cannot find global type 'NewableFunction'.
==== tests/cases/compiler/booleanLiteralsContextuallyTypedFromUnion.tsx (0 errors) ====
interface A { isIt: true; text: string; }
interface B { isIt: false; value: number; }
type C = A | B;
const isIt = Math.random() > 0.5;
const c: C = isIt ? { isIt, text: 'hey' } : { isIt, value: 123 };
const cc: C = isIt ? { isIt: isIt, text: 'hey' } : { isIt: isIt, value: 123 };
type ComponentProps =
| {
optionalBool: true;
mandatoryFn: () => void;
}
| {
optionalBool: false;
};
let Funk = (_props: ComponentProps) => <div>Hello</div>;
let Fail1 = () => <Funk mandatoryFn={() => { }} optionalBool={true} />
let Fail2 = () => <Funk mandatoryFn={() => { }} optionalBool={true as true} />
let True = true as true;
let Fail3 = () => <Funk mandatoryFn={() => { }} optionalBool={True} />
let attrs2 = { optionalBool: true as true, mandatoryFn: () => { } }
let Success = () => <Funk {...attrs2} />

View file

@ -41,7 +41,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
a1(...array2); // Error parameter type is (number|string)[]
~~~~~~
!!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'?
!!! related TS2728 /.ts/lib.es5.d.ts:1298:15: 'Array' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:1358:15: 'Array' is declared here.
a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]]
~~~~~~~~
!!! error TS2322: Type 'string' is not assignable to type '[[any]]'.

View file

@ -69,20 +69,20 @@ tests/cases/compiler/externModule.ts(37,3): error TS2552: Cannot find name 'XDat
var d=new XDate();
~~~~~
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
!!! related TS2728 /.ts/lib.es5.d.ts:837:15: 'Date' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:897:15: 'Date' is declared here.
d.getDay();
d=new XDate(1978,2);
~~~~~
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
!!! related TS2728 /.ts/lib.es5.d.ts:837:15: 'Date' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:897:15: 'Date' is declared here.
d.getXDate();
var n=XDate.parse("3/2/2004");
~~~~~
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
!!! related TS2728 /.ts/lib.es5.d.ts:837:15: 'Date' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:897:15: 'Date' is declared here.
n=XDate.UTC(1964,2,1);
~~~~~
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
!!! related TS2728 /.ts/lib.es5.d.ts:837:15: 'Date' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:897:15: 'Date' is declared here.

View file

@ -1,7 +1,8 @@
tests/cases/conformance/types/rest/genericRestArityStrict.ts(7,6): error TS2345: Argument of type '(x: number, y: number) => number' is not assignable to parameter of type '() => void'.
tests/cases/conformance/types/rest/genericRestArityStrict.ts(7,1): error TS2554: Expected 3 arguments, but got 1.
tests/cases/conformance/types/rest/genericRestArityStrict.ts(8,1): error TS2554: Expected 3 arguments, but got 8.
==== tests/cases/conformance/types/rest/genericRestArityStrict.ts (1 errors) ====
==== tests/cases/conformance/types/rest/genericRestArityStrict.ts (2 errors) ====
// Repro from #25559
declare function call<TS extends unknown[]>(
@ -9,7 +10,10 @@ tests/cases/conformance/types/rest/genericRestArityStrict.ts(7,6): error TS2345:
...args: TS): void;
call((x: number, y: number) => x + y);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number, y: number) => number' is not assignable to parameter of type '() => void'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 1.
!!! related TS6210 tests/cases/conformance/types/rest/genericRestArityStrict.ts:5:5: An argument for 'args' was not provided.
call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 8.

View file

@ -22,7 +22,7 @@ call((x: number, y: number) => x + y);
>y : number
call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7);
>call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7) : void
>call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7) : any
>call : <TS extends unknown[]>(handler: (...args: TS) => void, ...args: TS) => void
>(x: number, y: number) => x + y : (x: number, y: number) => number
>x : number

View file

@ -1,13 +1,9 @@
tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(20,46): error TS2322: Type '"y"' is not assignable to type '"x"'.
tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(21,19): error TS2322: Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x" | "y">'.
Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'LitProps<"x" | "y">'.
tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(21,19): error TS2322: Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'LitProps<"x">'.
Types of property 'children' are incompatible.
Type '(p: LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x" | "y">) => "x" | "y"'.
Types of parameters 'p' and 'x' are incompatible.
Type 'LitProps<"x" | "y">' is not assignable to type 'LitProps<"x">'.
Types of property 'prop' are incompatible.
Type '"x" | "y"' is not assignable to type '"x"'.
Type '"y"' is not assignable to type '"x"'.
Type '(p: LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x">) => "x"'.
Type '"y"' is not assignable to type '"x"'.
tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(22,21): error TS2322: Type '{ children: () => number; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
Type '{ children: () => number; prop: "x"; }' is not assignable to type 'LitProps<"x">'.
Types of property 'children' are incompatible.
@ -41,15 +37,11 @@ tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(22,21): error TS2322:
!!! related TS6502 tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx:13:44: The expected type comes from the return type of this signature.
const argchild = <ElemLit prop="x">{p => "y"}</ElemLit>
~~~~~~~
!!! error TS2322: Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x" | "y">'.
!!! error TS2322: Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'LitProps<"x" | "y">'.
!!! error TS2322: Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
!!! error TS2322: Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'LitProps<"x">'.
!!! error TS2322: Types of property 'children' are incompatible.
!!! error TS2322: Type '(p: LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x" | "y">) => "x" | "y"'.
!!! error TS2322: Types of parameters 'p' and 'x' are incompatible.
!!! error TS2322: Type 'LitProps<"x" | "y">' is not assignable to type 'LitProps<"x">'.
!!! error TS2322: Types of property 'prop' are incompatible.
!!! error TS2322: Type '"x" | "y"' is not assignable to type '"x"'.
!!! error TS2322: Type '"y"' is not assignable to type '"x"'.
!!! error TS2322: Type '(p: LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x">) => "x"'.
!!! error TS2322: Type '"y"' is not assignable to type '"x"'.
const mismatched = <ElemLit prop="x">{() => 12}</ElemLit>
~~~~~~~
!!! error TS2322: Type '{ children: () => number; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.

View file

@ -41,7 +41,7 @@ tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6FeaturesWithOnlyES5Lib.t
Math.sign(1);
~~~~
!!! error TS2551: Property 'sign' does not exist on type 'Math'. Did you mean 'sin'?
!!! related TS2728 /.ts/lib.es5.d.ts:643:5: 'sin' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:703:5: 'sin' is declared here.
// Using ES6 object
var o = {

View file

@ -24,7 +24,7 @@ tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts(16,17)
err.massage; // ERROR: Property 'massage' does not exist on type 'Error'
~~~~~~~
!!! error TS2551: Property 'massage' does not exist on type 'Error'. Did you mean 'message'?
!!! related TS2728 /.ts/lib.es5.d.ts:904:5: 'message' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:964:5: 'message' is declared here.
}
else {

View file

@ -22,7 +22,7 @@ tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts(22,7): error TS
x.mesage;
~~~~~~
!!! error TS2551: Property 'mesage' does not exist on type 'Error'. Did you mean 'message'?
!!! related TS2728 /.ts/lib.es5.d.ts:904:5: 'message' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:964:5: 'message' is declared here.
}
if (x instanceof Date) {
@ -30,6 +30,6 @@ tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts(22,7): error TS
x.getHuors();
~~~~~~~~
!!! error TS2551: Property 'getHuors' does not exist on type 'Date'. Did you mean 'getHours'?
!!! related TS2728 /.ts/lib.es5.d.ts:693:5: 'getHours' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:753:5: 'getHours' is declared here.
}

View file

@ -39,7 +39,7 @@ tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(33,7): error
x.mesage;
~~~~~~
!!! error TS2551: Property 'mesage' does not exist on type 'Error'. Did you mean 'message'?
!!! related TS2728 /.ts/lib.es5.d.ts:904:5: 'message' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:964:5: 'message' is declared here.
}
if (isDate(x)) {
@ -47,6 +47,6 @@ tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(33,7): error
x.getHuors();
~~~~~~~~
!!! error TS2551: Property 'getHuors' does not exist on type 'Date'. Did you mean 'getHours'?
!!! related TS2728 /.ts/lib.es5.d.ts:693:5: 'getHours' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:753:5: 'getHours' is declared here.
}

View file

@ -11,4 +11,4 @@ tests/cases/conformance/parser/ecmascript5/Expressions/parserMemberAccessAfterPo
!!! error TS1005: ';' expected.
~~~~~~~~
!!! error TS2552: Cannot find name 'toString'. Did you mean 'String'?
!!! related TS2728 /.ts/lib.es5.d.ts:457:15: 'String' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:517:15: 'String' is declared here.

View file

@ -19,7 +19,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS
$ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x));
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
//CHECK#2
@ -28,7 +28,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS
$ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x));
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}

View file

@ -21,7 +21,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.3_A1.1_T2.ts(17,3): error TS
$ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x));
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}

View file

@ -50,70 +50,70 @@ tests/cases/conformance/parser/ecmascript5/parserS7.6_A4.2_T1.ts(142,3): error T
$ERROR('#А');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0411 = 1;
if (Б !== 1) {
$ERROR('#Б');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0412 = 1;
if (В !== 1) {
$ERROR('#В');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0413 = 1;
if (Г !== 1) {
$ERROR('#Г');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0414 = 1;
if (Д !== 1) {
$ERROR('#Д');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0415 = 1;
if (Е !== 1) {
$ERROR('#Е');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0416 = 1;
if (Ж !== 1) {
$ERROR('#Ж');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0417 = 1;
if (З !== 1) {
$ERROR('#З');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0418 = 1;
if (И !== 1) {
$ERROR('#И');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0419 = 1;
if (Й !== 1) {
$ERROR('#Й');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u041A = 1;
if (К !== 1) {

View file

@ -11,13 +11,13 @@ tests/cases/conformance/parser/ecmascript5/parserUnicode1.ts(10,5): error TS2552
$ERROR('#6.1: var \\u0078x = 1; xx === 6. Actual: ' + (xx));
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
}
catch (e) {
$ERROR('#6.2: var \\u0078x = 1; xx === 6. Actual: ' + (xx));
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}

View file

@ -26,5 +26,5 @@ tests/cases/compiler/promiseTypeInference.ts(10,39): error TS2322: Type 'IPromis
!!! error TS2322: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2322: Type 'TResult1 | PromiseLike<TResult1>' is not assignable to type 'IPromise<TResult1 | TResult2>'.
!!! error TS2322: Type 'TResult1' is not assignable to type 'IPromise<TResult1 | TResult2>'.
!!! related TS6502 /.ts/lib.es5.d.ts:1336:57: The expected type comes from the return type of this signature.
!!! related TS6502 /.ts/lib.es5.d.ts:1396:57: The expected type comes from the return type of this signature.

View file

@ -19,7 +19,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.2_A1.5_T2.ts(20,3): error
$ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x));
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
//CHECK#2
@ -28,7 +28,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.2_A1.5_T2.ts(20,3): error
$ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x));
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}

View file

@ -21,7 +21,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.3_A1.1_T2.ts(17,3): error
$ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x));
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}

View file

@ -50,70 +50,70 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.6_A4.2_T1.ts(142,3): error
$ERROR('#А');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0411 = 1;
if (Б !== 1) {
$ERROR('#Б');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0412 = 1;
if (В !== 1) {
$ERROR('#В');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0413 = 1;
if (Г !== 1) {
$ERROR('#Г');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0414 = 1;
if (Д !== 1) {
$ERROR('#Д');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0415 = 1;
if (Е !== 1) {
$ERROR('#Е');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0416 = 1;
if (Ж !== 1) {
$ERROR('#Ж');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0417 = 1;
if (З !== 1) {
$ERROR('#З');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0418 = 1;
if (И !== 1) {
$ERROR('#И');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u0419 = 1;
if (Й !== 1) {
$ERROR('#Й');
~~~~~~
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
!!! related TS2728 /.ts/lib.es5.d.ts:914:15: 'Error' is declared here.
!!! related TS2728 /.ts/lib.es5.d.ts:974:15: 'Error' is declared here.
}
var \u041A = 1;
if (К !== 1) {

View file

@ -0,0 +1,139 @@
tests/cases/conformance/functions/strictBindCallApply1.ts(6,35): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(9,11): error TS2554: Expected 3 arguments, but got 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(10,35): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(11,11): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(14,32): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
Property '1' is missing in type '[number]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(15,37): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(16,32): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
Types of property 'length' are incompatible.
Type '3' is not assignable to type '2'.
tests/cases/conformance/functions/strictBindCallApply1.ts(29,29): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(30,22): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
tests/cases/conformance/functions/strictBindCallApply1.ts(33,11): error TS2554: Expected 3 arguments, but got 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(34,29): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(35,11): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(36,22): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
tests/cases/conformance/functions/strictBindCallApply1.ts(39,26): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(40,31): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(41,26): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(42,23): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
tests/cases/conformance/functions/strictBindCallApply1.ts(47,33): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(50,1): error TS2554: Expected 3 arguments, but got 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(51,15): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(52,1): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(55,12): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(56,17): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(57,12): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
==== tests/cases/conformance/functions/strictBindCallApply1.ts (24 errors) ====
declare function foo(a: number, b: string): string;
let f00 = foo.bind(undefined);
let f01 = foo.bind(undefined, 10);
let f02 = foo.bind(undefined, 10, "hello");
let f03 = foo.bind(undefined, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
let c00 = foo.call(undefined, 10, "hello");
let c01 = foo.call(undefined, 10); // Error
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 2.
let c02 = foo.call(undefined, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
let c03 = foo.call(undefined, 10, "hello", 30); // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 4.
let a00 = foo.apply(undefined, [10, "hello"]);
let a01 = foo.apply(undefined, [10]); // Error
~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
!!! error TS2345: Property '1' is missing in type '[number]'.
let a02 = foo.apply(undefined, [10, 20]); // Error
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
let a03 = foo.apply(undefined, [10, "hello", 30]); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
!!! error TS2345: Types of property 'length' are incompatible.
!!! error TS2345: Type '3' is not assignable to type '2'.
class C {
constructor(a: number, b: string) {}
foo(this: this, a: number, b: string): string { return "" }
}
declare let c: C;
declare let obj: {};
let f10 = c.foo.bind(c);
let f11 = c.foo.bind(c, 10);
let f12 = c.foo.bind(c, 10, "hello");
let f13 = c.foo.bind(c, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
let f14 = c.foo.bind(undefined); // Error
~~~~~~~~~
!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
let c10 = c.foo.call(c, 10, "hello");
let c11 = c.foo.call(c, 10); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 2.
let c12 = c.foo.call(c, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
let c13 = c.foo.call(c, 10, "hello", 30); // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 4.
let c14 = c.foo.call(undefined, 10, "hello"); // Error
~~~~~~~~~
!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
let a10 = c.foo.apply(c, [10, "hello"]);
let a11 = c.foo.apply(c, [10]); // Error
~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
let a12 = c.foo.apply(c, [10, 20]); // Error
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
let a13 = c.foo.apply(c, [10, "hello", 30]); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
let a14 = c.foo.apply(undefined, [10, "hello"]); // Error
~~~~~~~~~
!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
let f20 = C.bind(undefined);
let f21 = C.bind(undefined, 10);
let f22 = C.bind(undefined, 10, "hello");
let f23 = C.bind(undefined, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
C.call(c, 10, "hello");
C.call(c, 10); // Error
~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 2.
C.call(c, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
C.call(c, 10, "hello", 30); // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 4.
C.apply(c, [10, "hello"]);
C.apply(c, [10]); // Error
~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
C.apply(c, [10, 20]); // Error
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
C.apply(c, [10, "hello", 30]); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.

View file

@ -0,0 +1,107 @@
//// [strictBindCallApply1.ts]
declare function foo(a: number, b: string): string;
let f00 = foo.bind(undefined);
let f01 = foo.bind(undefined, 10);
let f02 = foo.bind(undefined, 10, "hello");
let f03 = foo.bind(undefined, 10, 20); // Error
let c00 = foo.call(undefined, 10, "hello");
let c01 = foo.call(undefined, 10); // Error
let c02 = foo.call(undefined, 10, 20); // Error
let c03 = foo.call(undefined, 10, "hello", 30); // Error
let a00 = foo.apply(undefined, [10, "hello"]);
let a01 = foo.apply(undefined, [10]); // Error
let a02 = foo.apply(undefined, [10, 20]); // Error
let a03 = foo.apply(undefined, [10, "hello", 30]); // Error
class C {
constructor(a: number, b: string) {}
foo(this: this, a: number, b: string): string { return "" }
}
declare let c: C;
declare let obj: {};
let f10 = c.foo.bind(c);
let f11 = c.foo.bind(c, 10);
let f12 = c.foo.bind(c, 10, "hello");
let f13 = c.foo.bind(c, 10, 20); // Error
let f14 = c.foo.bind(undefined); // Error
let c10 = c.foo.call(c, 10, "hello");
let c11 = c.foo.call(c, 10); // Error
let c12 = c.foo.call(c, 10, 20); // Error
let c13 = c.foo.call(c, 10, "hello", 30); // Error
let c14 = c.foo.call(undefined, 10, "hello"); // Error
let a10 = c.foo.apply(c, [10, "hello"]);
let a11 = c.foo.apply(c, [10]); // Error
let a12 = c.foo.apply(c, [10, 20]); // Error
let a13 = c.foo.apply(c, [10, "hello", 30]); // Error
let a14 = c.foo.apply(undefined, [10, "hello"]); // Error
let f20 = C.bind(undefined);
let f21 = C.bind(undefined, 10);
let f22 = C.bind(undefined, 10, "hello");
let f23 = C.bind(undefined, 10, 20); // Error
C.call(c, 10, "hello");
C.call(c, 10); // Error
C.call(c, 10, 20); // Error
C.call(c, 10, "hello", 30); // Error
C.apply(c, [10, "hello"]);
C.apply(c, [10]); // Error
C.apply(c, [10, 20]); // Error
C.apply(c, [10, "hello", 30]); // Error
//// [strictBindCallApply1.js]
"use strict";
var f00 = foo.bind(undefined);
var f01 = foo.bind(undefined, 10);
var f02 = foo.bind(undefined, 10, "hello");
var f03 = foo.bind(undefined, 10, 20); // Error
var c00 = foo.call(undefined, 10, "hello");
var c01 = foo.call(undefined, 10); // Error
var c02 = foo.call(undefined, 10, 20); // Error
var c03 = foo.call(undefined, 10, "hello", 30); // Error
var a00 = foo.apply(undefined, [10, "hello"]);
var a01 = foo.apply(undefined, [10]); // Error
var a02 = foo.apply(undefined, [10, 20]); // Error
var a03 = foo.apply(undefined, [10, "hello", 30]); // Error
var C = /** @class */ (function () {
function C(a, b) {
}
C.prototype.foo = function (a, b) { return ""; };
return C;
}());
var f10 = c.foo.bind(c);
var f11 = c.foo.bind(c, 10);
var f12 = c.foo.bind(c, 10, "hello");
var f13 = c.foo.bind(c, 10, 20); // Error
var f14 = c.foo.bind(undefined); // Error
var c10 = c.foo.call(c, 10, "hello");
var c11 = c.foo.call(c, 10); // Error
var c12 = c.foo.call(c, 10, 20); // Error
var c13 = c.foo.call(c, 10, "hello", 30); // Error
var c14 = c.foo.call(undefined, 10, "hello"); // Error
var a10 = c.foo.apply(c, [10, "hello"]);
var a11 = c.foo.apply(c, [10]); // Error
var a12 = c.foo.apply(c, [10, 20]); // Error
var a13 = c.foo.apply(c, [10, "hello", 30]); // Error
var a14 = c.foo.apply(undefined, [10, "hello"]); // Error
var f20 = C.bind(undefined);
var f21 = C.bind(undefined, 10);
var f22 = C.bind(undefined, 10, "hello");
var f23 = C.bind(undefined, 10, 20); // Error
C.call(c, 10, "hello");
C.call(c, 10); // Error
C.call(c, 10, 20); // Error
C.call(c, 10, "hello", 30); // Error
C.apply(c, [10, "hello"]);
C.apply(c, [10]); // Error
C.apply(c, [10, 20]); // Error
C.apply(c, [10, "hello", 30]); // Error

View file

@ -0,0 +1,322 @@
=== tests/cases/conformance/functions/strictBindCallApply1.ts ===
declare function foo(a: number, b: string): string;
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>a : Symbol(a, Decl(strictBindCallApply1.ts, 0, 21))
>b : Symbol(b, Decl(strictBindCallApply1.ts, 0, 31))
let f00 = foo.bind(undefined);
>f00 : Symbol(f00, Decl(strictBindCallApply1.ts, 2, 3))
>foo.bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>undefined : Symbol(undefined)
let f01 = foo.bind(undefined, 10);
>f01 : Symbol(f01, Decl(strictBindCallApply1.ts, 3, 3))
>foo.bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>undefined : Symbol(undefined)
let f02 = foo.bind(undefined, 10, "hello");
>f02 : Symbol(f02, Decl(strictBindCallApply1.ts, 4, 3))
>foo.bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>undefined : Symbol(undefined)
let f03 = foo.bind(undefined, 10, 20); // Error
>f03 : Symbol(f03, Decl(strictBindCallApply1.ts, 5, 3))
>foo.bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>undefined : Symbol(undefined)
let c00 = foo.call(undefined, 10, "hello");
>c00 : Symbol(c00, Decl(strictBindCallApply1.ts, 7, 3))
>foo.call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>undefined : Symbol(undefined)
let c01 = foo.call(undefined, 10); // Error
>c01 : Symbol(c01, Decl(strictBindCallApply1.ts, 8, 3))
>foo.call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>undefined : Symbol(undefined)
let c02 = foo.call(undefined, 10, 20); // Error
>c02 : Symbol(c02, Decl(strictBindCallApply1.ts, 9, 3))
>foo.call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>undefined : Symbol(undefined)
let c03 = foo.call(undefined, 10, "hello", 30); // Error
>c03 : Symbol(c03, Decl(strictBindCallApply1.ts, 10, 3))
>foo.call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>undefined : Symbol(undefined)
let a00 = foo.apply(undefined, [10, "hello"]);
>a00 : Symbol(a00, Decl(strictBindCallApply1.ts, 12, 3))
>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>undefined : Symbol(undefined)
let a01 = foo.apply(undefined, [10]); // Error
>a01 : Symbol(a01, Decl(strictBindCallApply1.ts, 13, 3))
>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>undefined : Symbol(undefined)
let a02 = foo.apply(undefined, [10, 20]); // Error
>a02 : Symbol(a02, Decl(strictBindCallApply1.ts, 14, 3))
>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>undefined : Symbol(undefined)
let a03 = foo.apply(undefined, [10, "hello", 30]); // Error
>a03 : Symbol(a03, Decl(strictBindCallApply1.ts, 15, 3))
>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0))
>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>undefined : Symbol(undefined)
class C {
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
constructor(a: number, b: string) {}
>a : Symbol(a, Decl(strictBindCallApply1.ts, 18, 16))
>b : Symbol(b, Decl(strictBindCallApply1.ts, 18, 26))
foo(this: this, a: number, b: string): string { return "" }
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>this : Symbol(this, Decl(strictBindCallApply1.ts, 19, 8))
>a : Symbol(a, Decl(strictBindCallApply1.ts, 19, 19))
>b : Symbol(b, Decl(strictBindCallApply1.ts, 19, 30))
}
declare let c: C;
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
declare let obj: {};
>obj : Symbol(obj, Decl(strictBindCallApply1.ts, 23, 11))
let f10 = c.foo.bind(c);
>f10 : Symbol(f10, Decl(strictBindCallApply1.ts, 25, 3))
>c.foo.bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let f11 = c.foo.bind(c, 10);
>f11 : Symbol(f11, Decl(strictBindCallApply1.ts, 26, 3))
>c.foo.bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let f12 = c.foo.bind(c, 10, "hello");
>f12 : Symbol(f12, Decl(strictBindCallApply1.ts, 27, 3))
>c.foo.bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let f13 = c.foo.bind(c, 10, 20); // Error
>f13 : Symbol(f13, Decl(strictBindCallApply1.ts, 28, 3))
>c.foo.bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let f14 = c.foo.bind(undefined); // Error
>f14 : Symbol(f14, Decl(strictBindCallApply1.ts, 29, 3))
>c.foo.bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>undefined : Symbol(undefined)
let c10 = c.foo.call(c, 10, "hello");
>c10 : Symbol(c10, Decl(strictBindCallApply1.ts, 31, 3))
>c.foo.call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let c11 = c.foo.call(c, 10); // Error
>c11 : Symbol(c11, Decl(strictBindCallApply1.ts, 32, 3))
>c.foo.call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let c12 = c.foo.call(c, 10, 20); // Error
>c12 : Symbol(c12, Decl(strictBindCallApply1.ts, 33, 3))
>c.foo.call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let c13 = c.foo.call(c, 10, "hello", 30); // Error
>c13 : Symbol(c13, Decl(strictBindCallApply1.ts, 34, 3))
>c.foo.call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let c14 = c.foo.call(undefined, 10, "hello"); // Error
>c14 : Symbol(c14, Decl(strictBindCallApply1.ts, 35, 3))
>c.foo.call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>call : Symbol(CallableFunction.call, Decl(lib.es5.d.ts, --, --))
>undefined : Symbol(undefined)
let a10 = c.foo.apply(c, [10, "hello"]);
>a10 : Symbol(a10, Decl(strictBindCallApply1.ts, 37, 3))
>c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let a11 = c.foo.apply(c, [10]); // Error
>a11 : Symbol(a11, Decl(strictBindCallApply1.ts, 38, 3))
>c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let a12 = c.foo.apply(c, [10, 20]); // Error
>a12 : Symbol(a12, Decl(strictBindCallApply1.ts, 39, 3))
>c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let a13 = c.foo.apply(c, [10, "hello", 30]); // Error
>a13 : Symbol(a13, Decl(strictBindCallApply1.ts, 40, 3))
>c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
let a14 = c.foo.apply(undefined, [10, "hello"]); // Error
>a14 : Symbol(a14, Decl(strictBindCallApply1.ts, 41, 3))
>c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
>foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 18, 40))
>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>undefined : Symbol(undefined)
let f20 = C.bind(undefined);
>f20 : Symbol(f20, Decl(strictBindCallApply1.ts, 43, 3))
>C.bind : Symbol(NewableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>bind : Symbol(NewableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>undefined : Symbol(undefined)
let f21 = C.bind(undefined, 10);
>f21 : Symbol(f21, Decl(strictBindCallApply1.ts, 44, 3))
>C.bind : Symbol(NewableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>bind : Symbol(NewableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>undefined : Symbol(undefined)
let f22 = C.bind(undefined, 10, "hello");
>f22 : Symbol(f22, Decl(strictBindCallApply1.ts, 45, 3))
>C.bind : Symbol(NewableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>bind : Symbol(NewableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>undefined : Symbol(undefined)
let f23 = C.bind(undefined, 10, 20); // Error
>f23 : Symbol(f23, Decl(strictBindCallApply1.ts, 46, 3))
>C.bind : Symbol(NewableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>bind : Symbol(NewableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more)
>undefined : Symbol(undefined)
C.call(c, 10, "hello");
>C.call : Symbol(NewableFunction.call, Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>call : Symbol(NewableFunction.call, Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
C.call(c, 10); // Error
>C.call : Symbol(NewableFunction.call, Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>call : Symbol(NewableFunction.call, Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
C.call(c, 10, 20); // Error
>C.call : Symbol(NewableFunction.call, Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>call : Symbol(NewableFunction.call, Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
C.call(c, 10, "hello", 30); // Error
>C.call : Symbol(NewableFunction.call, Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>call : Symbol(NewableFunction.call, Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
C.apply(c, [10, "hello"]);
>C.apply : Symbol(NewableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>apply : Symbol(NewableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
C.apply(c, [10]); // Error
>C.apply : Symbol(NewableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>apply : Symbol(NewableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
C.apply(c, [10, 20]); // Error
>C.apply : Symbol(NewableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>apply : Symbol(NewableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))
C.apply(c, [10, "hello", 30]); // Error
>C.apply : Symbol(NewableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(strictBindCallApply1.ts, 15, 50))
>apply : Symbol(NewableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(strictBindCallApply1.ts, 22, 11))

View file

@ -0,0 +1,441 @@
=== tests/cases/conformance/functions/strictBindCallApply1.ts ===
declare function foo(a: number, b: string): string;
>foo : (a: number, b: string) => string
>a : number
>b : string
let f00 = foo.bind(undefined);
>f00 : (a: number, b: string) => string
>foo.bind(undefined) : (a: number, b: string) => string
>foo.bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>foo : (a: number, b: string) => string
>bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>undefined : undefined
let f01 = foo.bind(undefined, 10);
>f01 : (b: string) => string
>foo.bind(undefined, 10) : (b: string) => string
>foo.bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>foo : (a: number, b: string) => string
>bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>undefined : undefined
>10 : 10
let f02 = foo.bind(undefined, 10, "hello");
>f02 : () => string
>foo.bind(undefined, 10, "hello") : () => string
>foo.bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>foo : (a: number, b: string) => string
>bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>undefined : undefined
>10 : 10
>"hello" : "hello"
let f03 = foo.bind(undefined, 10, 20); // Error
>f03 : any
>foo.bind(undefined, 10, 20) : any
>foo.bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>foo : (a: number, b: string) => string
>bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>undefined : undefined
>10 : 10
>20 : 20
let c00 = foo.call(undefined, 10, "hello");
>c00 : string
>foo.call(undefined, 10, "hello") : string
>foo.call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>foo : (a: number, b: string) => string
>call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>undefined : undefined
>10 : 10
>"hello" : "hello"
let c01 = foo.call(undefined, 10); // Error
>c01 : any
>foo.call(undefined, 10) : any
>foo.call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>foo : (a: number, b: string) => string
>call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>undefined : undefined
>10 : 10
let c02 = foo.call(undefined, 10, 20); // Error
>c02 : any
>foo.call(undefined, 10, 20) : any
>foo.call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>foo : (a: number, b: string) => string
>call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>undefined : undefined
>10 : 10
>20 : 20
let c03 = foo.call(undefined, 10, "hello", 30); // Error
>c03 : any
>foo.call(undefined, 10, "hello", 30) : any
>foo.call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>foo : (a: number, b: string) => string
>call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>undefined : undefined
>10 : 10
>"hello" : "hello"
>30 : 30
let a00 = foo.apply(undefined, [10, "hello"]);
>a00 : string
>foo.apply(undefined, [10, "hello"]) : string
>foo.apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>foo : (a: number, b: string) => string
>apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>undefined : undefined
>[10, "hello"] : [number, string]
>10 : 10
>"hello" : "hello"
let a01 = foo.apply(undefined, [10]); // Error
>a01 : any
>foo.apply(undefined, [10]) : any
>foo.apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>foo : (a: number, b: string) => string
>apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>undefined : undefined
>[10] : number[]
>10 : 10
let a02 = foo.apply(undefined, [10, 20]); // Error
>a02 : any
>foo.apply(undefined, [10, 20]) : any
>foo.apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>foo : (a: number, b: string) => string
>apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>undefined : undefined
>[10, 20] : number[]
>10 : 10
>20 : 20
let a03 = foo.apply(undefined, [10, "hello", 30]); // Error
>a03 : any
>foo.apply(undefined, [10, "hello", 30]) : any
>foo.apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>foo : (a: number, b: string) => string
>apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>undefined : undefined
>[10, "hello", 30] : (string | number)[]
>10 : 10
>"hello" : "hello"
>30 : 30
class C {
>C : C
constructor(a: number, b: string) {}
>a : number
>b : string
foo(this: this, a: number, b: string): string { return "" }
>foo : (this: this, a: number, b: string) => string
>this : this
>a : number
>b : string
>"" : ""
}
declare let c: C;
>c : C
declare let obj: {};
>obj : {}
let f10 = c.foo.bind(c);
>f10 : (a: number, b: string) => string
>c.foo.bind(c) : (a: number, b: string) => string
>c.foo.bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>c : C
let f11 = c.foo.bind(c, 10);
>f11 : (b: string) => string
>c.foo.bind(c, 10) : (b: string) => string
>c.foo.bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>c : C
>10 : 10
let f12 = c.foo.bind(c, 10, "hello");
>f12 : () => string
>c.foo.bind(c, 10, "hello") : () => string
>c.foo.bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>c : C
>10 : 10
>"hello" : "hello"
let f13 = c.foo.bind(c, 10, 20); // Error
>f13 : any
>c.foo.bind(c, 10, 20) : any
>c.foo.bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>c : C
>10 : 10
>20 : 20
let f14 = c.foo.bind(undefined); // Error
>f14 : any
>c.foo.bind(undefined) : any
>c.foo.bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>bind : { <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R; <T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; <T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; <T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R; <T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R; <T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R; }
>undefined : undefined
let c10 = c.foo.call(c, 10, "hello");
>c10 : string
>c.foo.call(c, 10, "hello") : string
>c.foo.call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>c : C
>10 : 10
>"hello" : "hello"
let c11 = c.foo.call(c, 10); // Error
>c11 : any
>c.foo.call(c, 10) : any
>c.foo.call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>c : C
>10 : 10
let c12 = c.foo.call(c, 10, 20); // Error
>c12 : any
>c.foo.call(c, 10, 20) : any
>c.foo.call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>c : C
>10 : 10
>20 : 20
let c13 = c.foo.call(c, 10, "hello", 30); // Error
>c13 : any
>c.foo.call(c, 10, "hello", 30) : any
>c.foo.call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>c : C
>10 : 10
>"hello" : "hello"
>30 : 30
let c14 = c.foo.call(undefined, 10, "hello"); // Error
>c14 : any
>c.foo.call(undefined, 10, "hello") : any
>c.foo.call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>call : <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R
>undefined : undefined
>10 : 10
>"hello" : "hello"
let a10 = c.foo.apply(c, [10, "hello"]);
>a10 : string
>c.foo.apply(c, [10, "hello"]) : string
>c.foo.apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>c : C
>[10, "hello"] : [number, string]
>10 : 10
>"hello" : "hello"
let a11 = c.foo.apply(c, [10]); // Error
>a11 : any
>c.foo.apply(c, [10]) : any
>c.foo.apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>c : C
>[10] : number[]
>10 : 10
let a12 = c.foo.apply(c, [10, 20]); // Error
>a12 : any
>c.foo.apply(c, [10, 20]) : any
>c.foo.apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>c : C
>[10, 20] : number[]
>10 : 10
>20 : 20
let a13 = c.foo.apply(c, [10, "hello", 30]); // Error
>a13 : any
>c.foo.apply(c, [10, "hello", 30]) : any
>c.foo.apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>c : C
>[10, "hello", 30] : (string | number)[]
>10 : 10
>"hello" : "hello"
>30 : 30
let a14 = c.foo.apply(undefined, [10, "hello"]); // Error
>a14 : any
>c.foo.apply(undefined, [10, "hello"]) : any
>c.foo.apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>c.foo : (this: C, a: number, b: string) => string
>c : C
>foo : (this: C, a: number, b: string) => string
>apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
>undefined : undefined
>[10, "hello"] : (string | number)[]
>10 : 10
>"hello" : "hello"
let f20 = C.bind(undefined);
>f20 : new (a: number, b: string) => C
>C.bind(undefined) : new (a: number, b: string) => C
>C.bind : { <A extends any[], R>(this: new (...args: A) => R, thisArg: any): new (...args: A) => R; <A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; <A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; <A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R; <A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R; <AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R; }
>C : typeof C
>bind : { <A extends any[], R>(this: new (...args: A) => R, thisArg: any): new (...args: A) => R; <A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; <A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; <A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R; <A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R; <AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R; }
>undefined : undefined
let f21 = C.bind(undefined, 10);
>f21 : new (b: string) => C
>C.bind(undefined, 10) : new (b: string) => C
>C.bind : { <A extends any[], R>(this: new (...args: A) => R, thisArg: any): new (...args: A) => R; <A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; <A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; <A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R; <A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R; <AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R; }
>C : typeof C
>bind : { <A extends any[], R>(this: new (...args: A) => R, thisArg: any): new (...args: A) => R; <A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; <A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; <A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R; <A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R; <AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R; }
>undefined : undefined
>10 : 10
let f22 = C.bind(undefined, 10, "hello");
>f22 : new () => C
>C.bind(undefined, 10, "hello") : new () => C
>C.bind : { <A extends any[], R>(this: new (...args: A) => R, thisArg: any): new (...args: A) => R; <A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; <A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; <A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R; <A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R; <AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R; }
>C : typeof C
>bind : { <A extends any[], R>(this: new (...args: A) => R, thisArg: any): new (...args: A) => R; <A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; <A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; <A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R; <A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R; <AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R; }
>undefined : undefined
>10 : 10
>"hello" : "hello"
let f23 = C.bind(undefined, 10, 20); // Error
>f23 : any
>C.bind(undefined, 10, 20) : any
>C.bind : { <A extends any[], R>(this: new (...args: A) => R, thisArg: any): new (...args: A) => R; <A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; <A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; <A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R; <A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R; <AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R; }
>C : typeof C
>bind : { <A extends any[], R>(this: new (...args: A) => R, thisArg: any): new (...args: A) => R; <A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; <A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; <A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R; <A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R; <AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R; }
>undefined : undefined
>10 : 10
>20 : 20
C.call(c, 10, "hello");
>C.call(c, 10, "hello") : void
>C.call : <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, ...args: A) => void
>C : typeof C
>call : <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, ...args: A) => void
>c : C
>10 : 10
>"hello" : "hello"
C.call(c, 10); // Error
>C.call(c, 10) : any
>C.call : <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, ...args: A) => void
>C : typeof C
>call : <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, ...args: A) => void
>c : C
>10 : 10
C.call(c, 10, 20); // Error
>C.call(c, 10, 20) : any
>C.call : <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, ...args: A) => void
>C : typeof C
>call : <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, ...args: A) => void
>c : C
>10 : 10
>20 : 20
C.call(c, 10, "hello", 30); // Error
>C.call(c, 10, "hello", 30) : any
>C.call : <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, ...args: A) => void
>C : typeof C
>call : <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, ...args: A) => void
>c : C
>10 : 10
>"hello" : "hello"
>30 : 30
C.apply(c, [10, "hello"]);
>C.apply(c, [10, "hello"]) : void
>C.apply : { <T>(this: new () => T, thisArg: T): void; <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void; }
>C : typeof C
>apply : { <T>(this: new () => T, thisArg: T): void; <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void; }
>c : C
>[10, "hello"] : [number, string]
>10 : 10
>"hello" : "hello"
C.apply(c, [10]); // Error
>C.apply(c, [10]) : any
>C.apply : { <T>(this: new () => T, thisArg: T): void; <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void; }
>C : typeof C
>apply : { <T>(this: new () => T, thisArg: T): void; <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void; }
>c : C
>[10] : number[]
>10 : 10
C.apply(c, [10, 20]); // Error
>C.apply(c, [10, 20]) : any
>C.apply : { <T>(this: new () => T, thisArg: T): void; <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void; }
>C : typeof C
>apply : { <T>(this: new () => T, thisArg: T): void; <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void; }
>c : C
>[10, 20] : number[]
>10 : 10
>20 : 20
C.apply(c, [10, "hello", 30]); // Error
>C.apply(c, [10, "hello", 30]) : any
>C.apply : { <T>(this: new () => T, thisArg: T): void; <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void; }
>C : typeof C
>apply : { <T>(this: new () => T, thisArg: T): void; <T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void; }
>c : C
>[10, "hello", 30] : (string | number)[]
>10 : 10
>"hello" : "hello"
>30 : 30

View file

@ -25,6 +25,7 @@
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

View file

@ -25,6 +25,7 @@
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

View file

@ -25,6 +25,7 @@
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

View file

@ -25,6 +25,7 @@
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

View file

@ -25,6 +25,7 @@
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

View file

@ -25,6 +25,7 @@
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

View file

@ -25,6 +25,7 @@
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

View file

@ -25,6 +25,7 @@
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

View file

@ -25,6 +25,7 @@
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

View file

@ -0,0 +1,59 @@
// @strict: true
declare function foo(a: number, b: string): string;
let f00 = foo.bind(undefined);
let f01 = foo.bind(undefined, 10);
let f02 = foo.bind(undefined, 10, "hello");
let f03 = foo.bind(undefined, 10, 20); // Error
let c00 = foo.call(undefined, 10, "hello");
let c01 = foo.call(undefined, 10); // Error
let c02 = foo.call(undefined, 10, 20); // Error
let c03 = foo.call(undefined, 10, "hello", 30); // Error
let a00 = foo.apply(undefined, [10, "hello"]);
let a01 = foo.apply(undefined, [10]); // Error
let a02 = foo.apply(undefined, [10, 20]); // Error
let a03 = foo.apply(undefined, [10, "hello", 30]); // Error
class C {
constructor(a: number, b: string) {}
foo(this: this, a: number, b: string): string { return "" }
}
declare let c: C;
declare let obj: {};
let f10 = c.foo.bind(c);
let f11 = c.foo.bind(c, 10);
let f12 = c.foo.bind(c, 10, "hello");
let f13 = c.foo.bind(c, 10, 20); // Error
let f14 = c.foo.bind(undefined); // Error
let c10 = c.foo.call(c, 10, "hello");
let c11 = c.foo.call(c, 10); // Error
let c12 = c.foo.call(c, 10, 20); // Error
let c13 = c.foo.call(c, 10, "hello", 30); // Error
let c14 = c.foo.call(undefined, 10, "hello"); // Error
let a10 = c.foo.apply(c, [10, "hello"]);
let a11 = c.foo.apply(c, [10]); // Error
let a12 = c.foo.apply(c, [10, 20]); // Error
let a13 = c.foo.apply(c, [10, "hello", 30]); // Error
let a14 = c.foo.apply(undefined, [10, "hello"]); // Error
let f20 = C.bind(undefined);
let f21 = C.bind(undefined, 10);
let f22 = C.bind(undefined, 10, "hello");
let f23 = C.bind(undefined, 10, 20); // Error
C.call(c, 10, "hello");
C.call(c, 10); // Error
C.call(c, 10, 20); // Error
C.call(c, 10, "hello", 30); // Error
C.apply(c, [10, "hello"]);
C.apply(c, [10]); // Error
C.apply(c, [10, 20]); // Error
C.apply(c, [10, "hello", 30]); // Error