I have 3 files with next content:
bark.ts
export function bark () {
console.log('My name', this.name);
}
Dog.ts
import {bark} from './bark';
class Dog {
name = 'Hachiko';
makeVoice = bark.bind(this);
}
index.ts
const dog = new Dog();
dog.makeVoice();
This example is working if I run it using clean JS (without TS). But when I use this example with typescript, this
has unknown type - compilation error.
So how to say to TS compiler type of this
in file bark.ts
.