TSConfig
strictBindCallApply
When set, TypeScript will check that the built-in methods of functions call
, bind
, and apply
are invoked with correct argument for the underlying function:
tsTry
// With strictBindCallApply onfunctionfn (x : string) {returnparseInt (x );}constn1 =fn .call (undefined , "10");constArgument of type 'boolean' is not assignable to parameter of type 'string'.2345Argument of type 'boolean' is not assignable to parameter of type 'string'.n2 =fn .call (undefined ,false );
Otherwise, these functions accept any arguments and will return any
:
tsTry
// With strictBindCallApply offfunctionfn (x : string) {returnparseInt (x );}// Note: No error; return type is 'any'constn =fn .call (undefined , false);