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
- Add a this parameter as the first parameter: function fn(this: MyClass, arg: string)
- Convert the function to an arrow function — arrow functions inherit this from the enclosing scope
- Bind the function explicitly: fn.bind(this) when passing as a callback
- 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.
