Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow ”as” ES6 keyword for Stencil’s decorators #3137

Closed
3 tasks done
splitinfinities opened this issue Nov 9, 2021 · 4 comments
Closed
3 tasks done

feat: Allow ”as” ES6 keyword for Stencil’s decorators #3137

splitinfinities opened this issue Nov 9, 2021 · 4 comments
Labels
Resolution: Refine This PR is marked for Jira refinement. We're not working on it - we're talking it through.

Comments

@splitinfinities
Copy link
Contributor

Prerequisites

Describe the Feature Request

The @Event and @Element decorators can be imported and can interfere with global types or be mistakenly used within the components.d.ts file. In those circumstances, it would be helpful for component authors to be able to alias the import like with the as keyword of es6 modules.

import { h, Event as StencilEvent, Element as StencilElement } from @stencil/core”;

//etc

Describe the Use Case

This feature allows component authors to use an aliased decorator that would be referred to within the components.d.ts file so that collisions can be reduced when interoping with global browser types.

Describe Preferred Solution

Open to perspective here, I’m not an expert on this.

Describe Alternatives

Maybe we could rename all the decorators? Or have alternate names that could be imported?

Open to perspective here, I’m not an expert on this.

Related Code

No response

Additional Information

No response

@rwaskiewicz
Copy link
Member

Potentially a part of the same problem/implementation space, but not the same problem: #3037

@rwaskiewicz
Copy link
Member

Related: stencil-community/stencil-eslint#28, although not the same issue

@rwaskiewicz rwaskiewicz added the Resolution: Refine This PR is marked for Jira refinement. We're not working on it - we're talking it through. label Nov 9, 2021
@rwaskiewicz
Copy link
Member

This issue has been labeled to be added to our internal backlog to be discussed as a team.

tanner-reits added a commit that referenced this issue Dec 11, 2023
The commit passes the aliased import name from the `ImportAliasMap` to each respective decorator transformer

Fixes: #3137

STENCIL-263
github-merge-queue bot pushed a commit that referenced this issue Dec 13, 2023
* create map of original imports to their aliased import

this commit creates a map of original import names to aliased import names. This will be used to get the aliased name of a decorator when parsing Stencil decorators to static component metadata

* change `importAliasMap` to class

This commit creates an `ImportAliasMap` class that extends the `Map` class. This makes it easy to instantiate, reference the underlying type, and clearly override the default getter

* pass aliased name to decorator parsers

The commit passes the aliased import name from the `ImportAliasMap` to each respective decorator transformer

Fixes: #3137

STENCIL-263

* add e2e tests for some aliased imports

* check namedBindings exist

* add rest of decorators to test
@rwaskiewicz
Copy link
Member

The fix for this issue has been released as a part of today's Stencil 4.9.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Refine This PR is marked for Jira refinement. We're not working on it - we're talking it through.
Projects
None yet
Development

No branches or pull requests

2 participants