【发布时间】:2022-10-09 01:10:04
【问题描述】:
我安装了@types/greensock 并开始使用gsap 和TypeScript。一切正常,但ScrollTo 插件给出了这个eslint 错误(附图片)。有人知道吗?
这是 eslint 错误:
这是我的.eslintrc:
{
"extends": "eslint:recommended",
"parser": "babel-eslint",
"env": {
"node": true,
"es6": true,
"browser": true
}
}
这是我的代码:
import { ScrollToPlugin } from "gsap/ScrollToPlugin";
import { gsap } from "gsap";
gsap.registerPlugin(ScrollToPlugin);
export const headerInteractionHandler = () => {
document.querySelector("header .logo").addEventListener("click", (e) => {
e.preventDefault();
let element = <HTMLAnchorElement>e.currentTarget;
gsap.to(window, {
duration: 0.8,
scrollTo: `${element.getAttribute("data-destination")}`,
});
});
};
【问题讨论】:
-
这是解析错误,而不是 lint 错误。你能给我们你的
.eslintrc吗? -
@MatthieuRiegler 我添加了它。感谢您的时间 !
-
您能否确认将解析器更改为
@typescript-eslint/parser可以解决问题? -
不,它没有。
-
由于您要迁移到 Typescript,我仍然建议您使用
@typescript-eslint/parser作为解析器,因为我将允许您进行类型检查。
标签: javascript typescript eslint gsap