Skip to content

[main] No type information for elements, custom-elements #808

@NullVoxPopuli

Description

@NullVoxPopuli

Example:

const ApplicationRoot: TOC<{ Element: null }> = <template>
  {{pageTitle "ExampleTsEmber"}}

  <custom-element />
    ^ hovering here: no type information
  <a></a>
   ^ hovering here: no type information
</template>;

export const Test: TOC<{}> = <template><ApplicationRoot /></template>;
                                        ^ hovering here: we see type information

now, it could be expected that custom-elements don't have type information, but the regular elements have known types, props, etc.

We also need a way to define custom-elements.

I briefly thought about the "loose mode" template registry:

declare module '@glint/environment-ember-loose/registry' {
  export default interface Registry extends PageTitle {
    'custom-element': ComponentLike<{ Element: HTMLDivElement }>;
  }
}

but:

  1. I'm not using loose mode
  2. custom-elements are not ComponentLike, so I'm not sure what I would provide for their type there

an example from @trusktr:

declare module 'whatever-framework' {
    interface WhateverInterface {
        'my-el': WhateverFrameworkElementAttributes<MyEl, MyElAttributes>
    }
}

maybe we can add this to support custom elements:

import { CustomElementLike } from '@glint/template';

declare module '@glint/core/custom-elements-registry' {
  export default interface Registry {
     'my-el': CustomElementLike<HTMLAnchorElement, MyAttributes>
  }
}

?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions