In JS, assignment to property of class has no contextual type #26748
Open
Description
opened on Aug 29, 2018
TypeScript Version: 3.1.0-dev.20180829
Code
class C {
/**
* @param {number} n
* @return {number}
*/
m = n => n * 2;
}
const c = new C();
c.m = n => n * 3;
Expected behavior:
No error.
Actual behavior:
src/a.js:10:7 - error TS7006: Parameter 'n' implicitly has an 'any' type.
There is no error for the equivalent TypeScript code (using m = (n: number): number => n * 2;
).
Related Issues:
Activity