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

fix(angular): support nested namespaces in event types #575

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

christian-bromann
Copy link
Member

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally for affected output targets
  • Tests (npm test) were run locally and passed
  • Prettier (npm run prettier) was run locally and passed

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Given someone would define a type like this:

export declare namespace IMyComponent {
  /** Variables */
  export type someVar = number;
  export namespace SomeMoreComplexType {
    export type SubType = string;
  }
}

and would use it as event type, e.g.:

import type { IMyComponent } from '../helpers';

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

  /**
   * Testing an event without value
   */
  @Event() myCustomEvent: EventEmitter<IMyComponent.someVar>;

  /**
   * Testing with nested namespaces
   */
  @Event() myCustomNestedEvent: EventEmitter<IMyComponent.SomeMoreComplexType.SubType>;

  // ...
}

Then we would not correctly resolve the type in the Angular proxies file, e.g.:

import type { IMyComponent as IMyComponentIMyComponent } from 'component-library';

export declare interface MyComponent extends Components.MyComponent {
  /**
   * Testing an event without value
   */
  myCustomEvent: EventEmitter<CustomEvent<IMyComponent.someVar>>;
  /**
   * Testing with nested namespaces
   */
  myCustomNestedEvent: EventEmitter<CustomEvent<IMyComponent.SomeMoreComplexType.SubType>>;
}

What is the new behavior?

With this patch we now resolve it correctly:

import type { IMyComponent as IMyComponentIMyComponent } from 'component-library';

export declare interface MyComponent extends Components.MyComponent {
  /**
   * Testing an event without value
   */
  myCustomEvent: EventEmitter<CustomEvent<IMyComponentIMyComponent.someVar>>;
  /**
   * Testing with nested namespaces
   */
  myCustomNestedEvent: EventEmitter<CustomEvent<IMyComponentIMyComponent.SomeMoreComplexType.SubType>>;
}

Does this introduce a breaking change?

  • Yes
  • No

Other information

n/a

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
christian-bromann Christian Bromann

Verified

This commit was signed with the committer’s verified signature.
christian-bromann Christian Bromann

Verified

This commit was signed with the committer’s verified signature.
christian-bromann Christian Bromann
@christian-bromann christian-bromann merged commit 419dacc into main Dec 18, 2024
3 checks passed
@christian-bromann christian-bromann deleted the cb/fix-nested-namespace branch December 18, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants