When working with VueJS in Javascript, I can achieve the following:
import debounce from "lodash/debounce";
...
watch: {
variable: debounce(function() {
console.log('wow');
}, 500)
}
However, when attempting to do the same in VueJS using Typescript, I encountered some issues:
npm i lodash-es
npm i @types/lodash-es -D
Within the component:
import { Component, Vue, Watch } from "vue-property-decorator";
import debounce from "lodash-es/debounce";
...
@Watch("variable")
debounce(function() {
console.log('wow');
}, 500)
Unfortunately, errors occurred:
- The 'debounce' function lacks a return type annotation and implicitly returns 'any'.
- The number '500' is implicitly assigned with the type 'any'.
P.S. The following method worked without any issues:
func = debounce(() => {
console.log('wow');
}, 500)