Skip to content

chore: fix i18n property type in CEM output using @type JSDoc overrides#11383

Open
web-padawan wants to merge 1 commit intomainfrom
chore/cem-type-override
Open

chore: fix i18n property type in CEM output using @type JSDoc overrides#11383
web-padawan wants to merge 1 commit intomainfrom
chore/cem-type-override

Conversation

@web-padawan
Copy link
Copy Markdown
Member

@web-padawan web-padawan commented Mar 20, 2026

Summary

Depends on #11381

  • The CEM analyzer's inheritance resolution overwrites subclass @type JSDoc overrides with the base mixin's generic type (e.g., Object from I18nMixin), even when a subclass getter has a more specific @type like @type {!AppLayoutI18n}
  • Add a two-phase CEM plugin: collects @type overrides from getter declarations during analyzePhase, then re-applies them in packageLinkPhase after CEM's own inheritance resolution has run
  • Uses BFS through the mixin/superclass chain to ensure the closest (most specific) override wins
  • Adds findClassNode helper that handles both class declarations and mixin patterns (including two-argument patterns like I18nMixin(defaultI18n, superClass) that extractMixinNodes cannot handle)
  • Extracts getJsDocTags helper reused across mixesPlugin, typeOverridePlugin, and classPrivacyPlugin

Test plan

  • Run yarn release:cem and verify no errors
  • Check i18n member types are component-specific, not generic Object:
    • packages/app-layout/custom-elements.jsonAppLayout.i18n should have type AppLayoutI18n
    • packages/date-picker/custom-elements.jsonDatePicker.i18n should have type DatePickerI18n
    • packages/crud/custom-elements.jsonCrud.i18n should have type CrudI18n

🤖 Generated with Claude Code

Base automatically changed from chore/cem-inherited-props to main March 23, 2026 09:39
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be applied to mixins? vaadin-date-picker-mixin still shows object. Same for attributes, though I'm not sure what "type" there even implies since those are always strings.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, sounds reasonable. I'll update the code to also fix this for mixins.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@web-padawan web-padawan force-pushed the chore/cem-type-override branch from cc4a303 to dbd9a3b Compare March 23, 2026 14:55
The CEM analyzer's inheritance resolution overwrites subclass @type
JSDoc overrides with the base mixin's generic type (e.g., Object from
I18nMixin). Add a two-phase plugin that collects @type overrides from
getter declarations during analyzePhase and re-applies them in
packageLinkPhase after inheritance resolution, using BFS to ensure
the closest (most specific) override wins.

Apply overrides to all declarations (classes and mixins) and update
both member and attribute types for consistency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@web-padawan web-padawan force-pushed the chore/cem-type-override branch from dbd9a3b to e1ecc47 Compare March 23, 2026 15:33
@sonarqubecloud
Copy link
Copy Markdown

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.

2 participants