简体   繁体   English

为什么 TS 不知道我在使用 Lit 的@property?

[英]Why doesn't TS know I am using @property from Lit?

I have the most basic Lit code like this:我有这样最基本的 Lit 代码:

import { property } from 'lit/decorators.js';

export class MyClass extends LitElement {
  @property()
  rows = [];
}

Outside of this sample, rows has data.在这个示例之外,行有数据。 My code renders as expected.我的代码按预期呈现。 However TS complains property is not being used?但是 TS 抱怨property没有被使用? Is there some setup I may be missing around TS and decorators?在 TS 和装饰器周围我可能缺少一些设置吗? I built the project using OWC .我使用OWC构建了项目。

显示代码中的 TS 错误的图像

Seems Open WC is out of date.似乎 Open WC 已经过时了。 It installs typescript lint at 4.33.0 when it needs 5.*它在需要5.*时在4.33.0安装 typescript lint

The general solution is listed here: Eslint wong error `is defined but never used` warning in NestJs for all decorators一般解决方案列在这里: Eslint wong error `is defined but never used` warning in NestJs for all decorators

I updated the generated package.json to this:我将生成的package.json更新为:

"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",

I restarted my ESLint server in VS Code and everything worked fine.我在 VS Code 中重启了我的 ESLint 服务器,一切正常。

It was nearly immediately fixed via https://github.com/open-wc/open-wc/issues/2557 when I reported it.当我报告它时,它几乎立即通过https://github.com/open-wc/open-wc/issues/2557修复了。

Leaving this question up for posterity.把这个问题留给后代。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM