ProjectStack
typescript

TS2683: 'this' implicitly has type 'any' because it does not have a type annotation

You're using this inside a function where TypeScript can't determine what this refers to. Unlike class methods where this is well-typed, standalone functions and callbacks can have unpredictable this values, so TypeScript requires an explicit this parameter when strict mode is on.

Common causes

  • Using this inside a regular function passed as a callback or event handler
  • noImplicitThis or strict mode enabled — TypeScript requires this to be typed explicitly
  • A class method extracted into a standalone function still using this
  • Using this in a function that gets called with .call() or .apply() with varying contexts

How to fix it

  1. Add a this parameter as the first parameter: function fn(this: MyClass, arg: string)
  2. Convert the function to an arrow function — arrow functions inherit this from the enclosing scope
  3. Bind the function explicitly: fn.bind(this) when passing as a callback
  4. Use a class method instead of a standalone function when you need typed this access

Example

function handleClick() { console.log(this.value); // error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. }

Using this in a standalone function without a this parameter annotation in strict mode

Browse more errors

The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.