I have the following project:
which contains the following two files:
custom-container.tsx
import { Component, Element, State } from '@stencil/core';
@Component({
tag: 'custom-container',
styleUrl: 'custom-container.scss',
})
export class WebComponent {
@Element() el!: HTMLStencilElement;
@State() label: String = '<empty>';
componentDidLoad() {
document.querySelector('.button_get_anchor').addEventListener('click', () => {
let position = '<unset>';
position = this.el.querySelector('custom-details').getDefaultKnobEPosition();
this.label = position;
});
}
render() {
return [
<div class="label">{this.label}</div>,
<custom-details></custom-details>,
<div>
<button class="button_get_anchor">Get Anchor</button>
</div>
];
}
}
custom-details.tsx
import { Component, Method } from '@stencil/core';
@Component({
tag: 'custom-details',
styleUrl: 'custom-details.scss',
})
export class WebComponent {
render() {
return [
<div class="details">This is the "custom-details"</div>
];
}
@Method()
sayHelloWorldOnConsole() {
console.log('Hello World!');
}
//*
@Method()
getDefaultKnobEPosition(): Anchor {
return Anchor.Left;
}
//*/
}
export enum Anchor {
Left = 'left',
Center = 'center',
Right = 'right',
}
My problem is: When I run:
$ npm start --es5
I get the following error:
[ ERROR ] TypeScript: ./stencil-cannot-find-name/src/components.d.ts:66:39
Cannot find name 'Anchor'.
L65: interface CustomDetails {
L66: 'getDefaultKnobEPosition': () => Anchor;
L67: 'sayHelloWorldOnConsole': () => void;
[21:56.0] dev server: http://localhost:3333/
[21:56.0] build failed, watching for changes... in
15.59 s
as you can see on the following image:
Also, even before compiling with npm
, on the Visual Studio Code
I get notified about that issue, as you can see on the following image:
Here is the line that is causing the problem:
where that file above is auto-generated
, so I cannot modify it in order to fix the issue.
Any idea on how to solve this?
Thanks!