Skip to content

Commit

Permalink
Test to not report missing element type definitions when tag names wh…
Browse files Browse the repository at this point in the history
…ich are static class properties. Requires runem/web-component-analyzer#279
  • Loading branch information
driesva committed Nov 24, 2023
1 parent a8278e2 commit e20f510
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tsTest("'no-missing-element-type-definition' reports diagnostic when element is
hasDiagnostic(t, diagnostics, "no-missing-element-type-definition");
});

tsTest("'no-missing-element-type-definition' reports no diagnostic when element is not in HTMLElementTagNameMap", t => {
tsTest("'no-missing-element-type-definition' reports no diagnostic when element is in HTMLElementTagNameMap", t => {
const { diagnostics } = getDiagnostics(
`
class MyElement extends HTMLElement { };
Expand All @@ -34,3 +34,24 @@ tsTest("'no-missing-element-type-definition' reports no diagnostic when element

hasNoDiagnostics(t, diagnostics);
});

tsTest("'no-missing-element-type-definition' reports no diagnostic when element is in HTMLElementTagNameMap using class property", t => {
const { diagnostics } = getDiagnostics(
`
class MyElement extends HTMLElement {
static readonly TAG_NAME = "my-element"
};
customElements.define(MyElement.TAG_NAME, MyElement)
declare global {
interface HTMLElementTagNameMap {
[MyElement.TAG_NAME]: MyElement
}
}
`,
{
rules: { "no-missing-element-type-definition": true }
}
);

hasNoDiagnostics(t, diagnostics);
});

0 comments on commit e20f510

Please sign in to comment.