We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let's say in a file with Lit component I have an interface that describes props:
export interface ButtonProps { variant: 'primary' | 'secondary' | 'tertiary' size: 'sm' | 'md' | 'lg' }
Then I reference it for a property:
export class Button extends LitElement { @property({ type: String }) variant: ButtonProps["variant"] = "primary"; ...
There is no expandedType generated in custom-elements.json. The result looks like this:
expandedType
custom-elements.json
... { "kind": "field", "name": "variant", "type": { "text": "ButtonProps[\"variant\"]" }, "default": "\"primary\"", "attribute": "variant" }, ...
Expected result:
... { "kind": "field", "name": "variant", "type": { "text": "ButtonProps[\"variant\"]" }, "default": "\"primary\"", "attribute": "variant", "expandedType": { "text": "'primary' | 'secondary' | 'tertiary'" } }, ...
The text was updated successfully, but these errors were encountered:
"computed types" like these, generics, and other TS functions are difficult for the analyzer to parse. I haven't found a good way to do that yet.
Out of curiosity if you set it to a new type, does it work?
type ButtonVariants = ButtonProps["variant"]; export class Button extends LitElement { @property({ type: String }) variant: ButtonVariants = "primary"; ...
Sorry, something went wrong.
It looks like this is working in my new package: https://wc-toolkit.com/documentation/type-parser/
Here is an example: https://stackblitz.com/edit/stackblitz-starters-but1bogc?file=src%2Fmy-component.ts
No branches or pull requests
Let's say in a file with Lit component I have an interface that describes props:
Then I reference it for a property:
There is no
expandedType
generated incustom-elements.json
. The result looks like this:Expected result:
The text was updated successfully, but these errors were encountered: