Matsuuu / custom-elements-language-server

Custom Elements Language Server provides useful language features for Web Components. Features include code actions, completions, diagnostics and more.
BSD 3-Clause "New" or "Revised" License
84 stars 0 forks source link

Report type errors in attributes & properties of elements #17

Open Matsuuu opened 1 year ago

Matsuuu commented 1 year ago

Given I have an elements

export type ComponentVariant = "default" | "primary" | "secondary";

class MyComponent extends LitElement {
    @property({ type: String })
    variant: ComponentVariant = "default";
}

I would want to get diagnostic help when the typing of my attribute doesn't match the one provided.

e.g.

<my-component variant="foobar"></my-component>

Should throw an diagnostics error and underline the variant="foobar" section of the component with an error message like Type '"foobar"' is not assignable to type 'ComponentVariant'

Matsuuu commented 1 year ago

Some stuff related to this is here: https://github.com/Matsuuu/tsc-checker-demoing

Will be continuing on this work next as this will be a major feature