Closed
Description
Same situation than #23040, but using an intermediate function instead of using "!".
TypeScript Version: 2.9.0-dev.20180410
Search Terms: "'this' context of type 'void' is not assignable"
Code
interface Foo {
required: ((this: Foo) => void);
optional: ((this: Foo) => void) | null;
}
function notNull<T>(value: T): NonNullable<T> {
if (value == null) throw Error("notNull() failed");
return value as NonNullable<T>;
}
declare const foo: Foo;
foo.required();
foo.optional!(); // Fixed by #23040.
notNull(foo.optional)(); // Error.
Expected behavior:
No Error.
Actual behavior:
The 'this' context of type 'void' is not assignable to method's 'this' of type 'Foo'.
Related Issues: #23040