You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change Element decorator name or allow typescript as syntax #2074
Current behavior:
the Element decorator name is conflicting with the global Element type for DOM elements. There is no namespacing for these globals, so I can't reference them any other way, and when I tried to use the typescript as syntax for importing, stencil generated code that simply did not work while typescript isn't showing any issues. I also tried it with import * as stencil from '@stencil/core'; so I could add the decorator with @stencil.Element, but that didn't work either.
Expected behavior:
I would expect that Stencil wouldn't try to conflict with global types, or if they did, make it easy to change it to prevent this from happening. At this time, the type for my element variable is a function, which is wrong and makes it harder to develop with.
Steps to reproduce:
See code below.
Related code:
import{Component,Element,Prop,State,Watch}from'@stencil/core';// this doesn't work: import {Element as RootElement} from '@stencil/core';// neither does this: import * as stencil from '@stencil/core';
@Component({tag: 'nx-icon',styleUrl: `icon.scss`,shadow: false})exportclassIconComponent{
@Element()rootElement: HTMLElement;element: Element;// trying to save a dynamically created element, but the type is the decorator function, not the DOM Element}
Another example of problematic situation with Event annotation:
import{Component,Event,EventEmitter}from'@stencil/core'
@Component()exportclassDemoComponent{
@Event()myEvent: EventEmitter<never>render(): unknown{return<formonSubmit={this.onFormSubmitted}/>}privatereadonlyonFormSubmitted=(e: Event/* Fails here because it is not the correct Event interface! */): void=>{e.stopPropagation()this.myEvent.emit()}}
So a rename of the problematic elements (at least Element and Event), or the support the as syntax would be mostly appreciated!
Sorry there has been no reply from the team here. I just took a look at this with the latest version of Stencil and can confirm import aliasing is not working! Looking through the existing Stencil issue, it appears we have a few different issues related to the same problem, but #3137 seems to cover them all.
That being said, I'll get this issue labeled accordingly for the team to track. But, I would advise keeping an eye on the mentioned issue for updates as that work progresses.
Activity
Nightmaster commentedon Jun 11, 2020
Another example of problematic situation with
Eventannotation:So a rename of the problematic elements (at least
ElementandEvent), or the support theassyntax would be mostly appreciated!Nightmaster commentedon Jun 19, 2020
@adamdbradley @manucorporat
mmakrzem commentedon Sep 9, 2020
I have a similar problem that I reported in #2563
Any idea's how to "fix/hack" stencil to allow me to use "Element" in my stencil components?
tanner-reits commentedon Jan 31, 2023
Hey all 👋
Sorry there has been no reply from the team here. I just took a look at this with the latest version of Stencil and can confirm import aliasing is not working! Looking through the existing Stencil issue, it appears we have a few different issues related to the same problem, but #3137 seems to cover them all.
That being said, I'll get this issue labeled accordingly for the team to track. But, I would advise keeping an eye on the mentioned issue for updates as that work progresses.
Thanks!
tanner-reits commentedon Dec 11, 2023
Closing as duplicate of #3137