admin管理员组文章数量:1122846
So I am having trouble with VS Code not recognizing the @ property decorator.
So I created the most basic Lit component.
import { LitElement, html } from 'lit';
import { property } from 'lit/decorators.js';
class MyComponent extends LitElement {
@property({ type: String }) myProperty = '';
render() {
return html`<div>${this.myProperty}</div>`;
}
}
customElements.define('my-component', MyComponent);
But I still get a red line under property({ type: String }) and I can't figure out why. It seems to recognize property in the import because that doesn't have a red underline. I don't have red underlines for the imports. I am on typescript 5.7.2 and Lit 3.2.1. Since the most basic Lit example doesn't work I suspect my settings. I have these settings in my tsconfig as I was reading that may be relevent:
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "Node"
}
I can pull up any webpack settings you may feel would be relevant.
I don't know what else could be causing it.
The error I get when hovering over "property" is below (I put it at the end since it is kind of long):
Unable to resolve signature of property decorator when called as an expression. No overload matches this call. Overload 1 of 3, '(target: ClassAccessorDecoratorTarget<MyComponent, string>, context: ClassAccessorDecoratorContext<MyComponent, string>): ClassAccessorDecoratorResult<...>', gave the following error. Argument of type 'undefined' is not assignable to parameter of type 'ClassAccessorDecoratorTarget<MyComponent, string>'. Overload 2 of 3, '(target: (value: string) => void, context: ClassSetterDecoratorContext<MyComponent, string>): (this: MyComponent, value: string) => void', gave the following error. Argument of type 'undefined' is not assignable to parameter of type '(value: string) => void'. Overload 3 of 3, '(protoOrDescriptor: Object, name: PropertyKey, descriptor?: PropertyDescriptor | undefined): any', gave the following error. Argument of type 'undefined' is not assignable to parameter of type 'Object'.ts(1240) Decorator function return type 'ClassAccessorDecoratorResult<MyComponent, string>' is not assignable to type 'void | ((this: MyComponent, value: string) => string)'.ts(1270)
本文标签: typescriptproperty not being recognized in LitStack Overflow
版权声明:本文标题:typescript - property not being recognized in Lit - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283373a1926947.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论