I am developing with vuejs using typescript and facing issues with method callback working. I am basically trying to update my data by wrapping it in a debounce function. I am using debounce function from https://www.npmjs.com/package/ts-debounce module. Here is the code example:
import { debounce } from 'ts-debounce';
export default Vue.extend({
name: 'HelloWorld',
data() {
return {
input: '# hello',
};
},
methods: {
updateWithDebounce: debounce(function(e: any) {
this.input = e.target.value;
}, 2000),
update(e: any) {
this.input = e.target.value;
},
}
This code functionally works, but fails with compilation error:
'this' implicitly has type 'any' because it does not have a type annotation.
40 |
41 | updateWithDebounce: debounce(function(e: any) {
> 42 | this.input = e.target.value;
| ^
43 | }, 2000),
Would greatly appreciate if someone can help me resolve this error.