<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨 Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section! Please help us by doing the following steps before logging an issue: * Search: https://github.com/Microsoft/TypeScript/search?type=Issues * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ Please fill in the *entire* template below. --> <!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. --> **TypeScript Version:** 3.3.3 <!-- Search terms you tried before logging this (so others can find this issue more easily) --> **Search Terms:** noImplicitAny, context **Code** ```ts function foo(num: number) { this.num = num; } ``` **Expected behavior:** When I hover over `this` I should see `void` as the implicitly inferred type. Ideally `this.num` would be an error, especially in strict mode. **Actual behavior:** I see `any` as the implicit type of `this`. `this` is always inferred to be `any` unless I override it in the function signature. **Playground Link:** <!-- A link to a TypeScript Playground "Share" link which demonstrates this behavior --> Bad: https://www.typescriptlang.org/play/index.html#src=type%20Context%20%3D%20%7B%0D%0A%20%20%20%20num%3A%20number%2C%0D%0A%7D%0D%0A%0D%0Afunction%20foo(num%3A%20number)%20%7B%0D%0A%20%20this.num%20%3D%20num%3B%0D%0A%7D Good: https://www.typescriptlang.org/play/index.html#src=type%20Context%20%3D%20%7B%0D%0A%20%20%20%20num%3A%20number%2C%0D%0A%7D%0D%0A%0D%0Afunction%20foo(this%3A%20Context%2C%20num%3A%20number)%20%7B%0D%0A%20%20this.num%20%3D%20num%3B%0D%0A%7D
TypeScript Version: 3.3.3
Search Terms: noImplicitAny, context
Code
Expected behavior:
When I hover over
thisI should seevoidas the implicitly inferred type. Ideallythis.numwould be an error, especially in strict mode.Actual behavior:
I see
anyas the implicit type ofthis.thisis always inferred to beanyunless I override it in the function signature.Playground Link:
Bad: https://www.typescriptlang.org/play/index.html#src=type%20Context%20%3D%20%7B%0D%0A%20%20%20%20num%3A%20number%2C%0D%0A%7D%0D%0A%0D%0Afunction%20foo(num%3A%20number)%20%7B%0D%0A%20%20this.num%20%3D%20num%3B%0D%0A%7D
Good: https://www.typescriptlang.org/play/index.html#src=type%20Context%20%3D%20%7B%0D%0A%20%20%20%20num%3A%20number%2C%0D%0A%7D%0D%0A%0D%0Afunction%20foo(this%3A%20Context%2C%20num%3A%20number)%20%7B%0D%0A%20%20this.num%20%3D%20num%3B%0D%0A%7D