<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨 --> <!-- Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Please help us by doing the following steps before logging an issue: * Search: https://github.com/Microsoft/TypeScript/search?type=Issues * Read the CONTRIBUTING guidelines: https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ --> <!-- If you have a QUESTION: THIS IS NOT A FORUM FOR QUESTIONS. Ask questions at http://stackoverflow.com/questions/tagged/typescript or https://gitter.im/Microsoft/TypeScript --> <!-- If you have a SUGGESTION: Most suggestion reports are duplicates, please search extra hard before logging a new suggestion. See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md --> <!-- If you have a BUG: Please fill in the *entire* template below. --> I hit a regression trying to upgrade to the latest version. <!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. --> **TypeScript Version:** Tested with 2.8.1 and 2.9.0-dev.20180330 <!-- Search terms you tried before logging this (so others can find this issue more easily) --> **Search Terms:** * non null assertion * The 'this' context of type 'void' **Code** ```ts interface Foo { required: ((this: Foo) => void); optional: ((this: Foo) => void) | null; } declare const foo: Foo; foo.required(); foo.optional!(); ``` **Expected behavior:** Successful compilation **Actual behavior:** Error on the last line: ``` The 'this' context of type 'void' is not assignable to method's 'this' of type 'HTMLElement'. ``` **Playground Link:** <!-- A link to a TypeScript Playground "Share" link which demonstrates this behavior --> https://www.typescriptlang.org/play/index.html#src=interface%20Foo%20%7B%0D%0A%20%20%20%20required%3A%20((this%3A%20Foo)%20%3D>%20void)%3B%0D%0A%20%20%20%20optional%3A%20((this%3A%20Foo)%20%3D>%20void)%20%7C%20null%3B%0D%0A%7D%0D%0A%0D%0Adeclare%20const%20foo%3A%20Foo%3B%0D%0Afoo.required()%3B%0D%0Afoo.optional!()%3B **Related Issues:** N/A
I hit a regression trying to upgrade to the latest version.
TypeScript Version: Tested with 2.8.1 and 2.9.0-dev.20180330
Search Terms:
Code
Expected behavior:
Successful compilation
Actual behavior:
Error on the last line:
Playground Link:
https://www.typescriptlang.org/play/index.html#src=interface%20Foo%20%7B%0D%0A%20%20%20%20required%3A%20((this%3A%20Foo)%20%3D>%20void)%3B%0D%0A%20%20%20%20optional%3A%20((this%3A%20Foo)%20%3D>%20void)%20%7C%20null%3B%0D%0A%7D%0D%0A%0D%0Adeclare%20const%20foo%3A%20Foo%3B%0D%0Afoo.required()%3B%0D%0Afoo.optional!()%3B
Related Issues:
N/A