For instance:
interface Foo {
someProperty: Number
someMethod?: (str: string) => void
}
class Bar implements Foo {
someProperty = 42
someMethod (str) {
console.log(this.someProperty)
}
}
The str
argument in someMethod()
is clearly a string. However, the compiler throws an error:
test.tsx(8,15): error TS7006: Parameter 'str' implicitly has an 'any' type.
What mistake am I making?
Edit: tsc --version
indicates version 2.8.3.