Course contentsShow
← TypeScript
Lesson 1184 of 1,79628. tsconfig in DepthFree lesson

strictBindCallApply

Type-checking bind, call, and apply methods to ensure arguments match function signatures.

What You'll Learn

You'll learn how TypeScript's strictBindCallApply flag makes .bind(), .call(), and .apply() safer by checking that the arguments you pass actually match the function's signature.

The Problem Without strictBindCallApply

In JavaScript, bind, call, and apply are powerful methods that let you invoke functions with a specific this context and arguments. But without strict checking, TypeScript treats them loosely—it doesn't verify that the arguments you're passing actually match what the function expects.

Think of it like addressing an envelope: without this flag, TypeScript lets you write any address format you want. With the flag enabled, it checks that you've included the street, city, and postal code in the right order.

How strictBindCallApply Works

When enabled (automatically included in strict: true), TypeScript analyzes the original function's parameter types and enforces them when you use:

  • .call(thisArg, ...args) — invokes immediately with explicit arguments
  • .apply(thisArg, argsArray) — invokes immediately with an array of arguments
  • .bind(thisArg, ...args) — returns a new function with bound context and partial arguments

Without this flag, these methods accept any arguments. With it, TypeScript checks argument count, types, and order against the function signature.

Real-World Impact

This prevents common mistakes like passing the wrong number of arguments, swapping argument order, or using incompatible types—errors that would only surface at runtime otherwise.

Key Takeaway: strictBindCallApply brings compile-time type safety to JavaScript's function invocation methods, catching argument mismatches before your code runs.