我在astro中有一个照明组件:
import { html } from 'lit';
import { customElement, property } from "lit/decorators.js";
import { StyledTailwindElement } from '../shared/tailwind.element';
import style from "./test.component.scss?inline";
@customElement("text-input")
export class TextInput extends StyledTailwindElement(style) {
@property({ type: String }) placeholder = '';
@property({ type: String }) name = '';
render() {
return html`
<input type="text" placeholder="${this.placeholder}" name="${this.name}"/>
`;
}
}
字符串
和
---
import { TextInput } from "../lit-tailwind/form/text-input.ts"
---
<TextInput name="exmaple"></TextInput>
型
我得到了:
的数据
Type '{ name: string; }' is not assignable to type 'IntrinsicAttributes'.
Property 'name' does not exist on type 'IntrinsicAttributes'.ts(2322)
(property) name: string
型
我怎样才能获得点亮元素的类型安全?我尝试从text-input.ts
导出Props
。
1条答案
按热度按时间4ioopgfo1#
不幸的是,目前似乎不支持intellisense。
这是一个官方贡献者最近对这个主题的回答:
我们目前不支持Lit组件智能感知
关于在不久的将来提供此功能的可能性,看起来它不是一个优先事项。
在不久的将来,我会说这是不太可能的,除非有人贡献它,这是一个相当大的工作量,我们没有那么多的Lit用户一般
以下是官方astrojs不和谐频道的对话链接。
https://discord.com/channels/830184174198718474/1166792409301123124/1171190200974704772