Skip to content

feat: allow imports of reusable Enum types #6030

@MatteoFeltrin

Description

@MatteoFeltrin

Prerequisites

Stencil Version

4.22

Current Behavior

Inside a component we have this code:

// ...
// omitted useless code
// ...

export interface ConfirmationService {
    confirm(): void;
}

@Component({
    tag: 'my-component',
    shadow: true,
})
export class MyComponent{
// ...
// omitted useless code
// ...

Everything is compiling and working correctly.
This works only with interface, exporting Classes or Functions throws an error.
Is this fine and we can do that, or it may lead to unexpected behaviour and problems with the bundling as documented?

Expected Behavior

As documented here https://stenciljs.com/docs/module-bundling#one-component-per-module I would expect the compiler to throw something like:

[ ERROR ]  src/components/my-component.tsx:4:1
        To allow efficient bundling, modules using @Component() can only have a single export which is the component
        class itself. Any other exports should be moved to a separate file. For further information check out:
        https://stenciljs.com/docs/module-bundling

  L4:  export interface ConfirmationService()

System Info

No response

Steps to Reproduce

Export an interface from a component entry point.

Code Reproduction URL

none

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within StencilHelp Wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions