"this" 隐式具有类型 "any",因为它没有类型注释。(“this” implicitly has type “any” because it does not have a type annotation )
2025-01-01 20:14:12一. 问题
"this" 隐式具有类型 "any",因为它没有类型注释。 “this” implicitly has type “any” because it does not have a type annotation 。
二. 解决方案
将 this 放在函数参数列表上声明类型即可,使用的时候 this 不会干扰形参传入顺序。如下:
const fn = () => {
return function (this: any, ...args: any[]) {
return this;
};
};