feat(codegen): type wc-ready events in declarations
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
30f64a3d59
commit
a388848626
2 changed files with 10 additions and 0 deletions
|
|
@ -140,6 +140,13 @@ func GenerateTypeDefinitions(slots map[string]string) (string, error) {
|
|||
}
|
||||
|
||||
b.WriteString("\ndeclare global {\n")
|
||||
b.WriteString(" interface WcReadyDetail {\n")
|
||||
b.WriteString(" tag: string;\n")
|
||||
b.WriteString(" slot: string;\n")
|
||||
b.WriteString(" }\n")
|
||||
b.WriteString(" interface HTMLElementEventMap {\n")
|
||||
b.WriteString(` "wc-ready": CustomEvent<WcReadyDetail>;` + "\n")
|
||||
b.WriteString(" }\n")
|
||||
b.WriteString(" interface HTMLElementTagNameMap {\n")
|
||||
for _, entry := range entries {
|
||||
if !isValidCustomElementTag(entry.Tag) {
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ func TestGenerateTypeDefinitions_Good(t *testing.T) {
|
|||
dts, err := GenerateTypeDefinitions(slots)
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, dts, "declare global")
|
||||
assert.Contains(t, dts, "interface WcReadyDetail")
|
||||
assert.Contains(t, dts, `interface HTMLElementEventMap`)
|
||||
assert.Contains(t, dts, `"wc-ready": CustomEvent<WcReadyDetail>;`)
|
||||
assert.Contains(t, dts, "class NavBar extends HTMLElement")
|
||||
assert.Contains(t, dts, "class MainContent extends HTMLElement")
|
||||
assert.Contains(t, dts, `"nav-bar": NavBar;`)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue