Skip to content

feat: add support for mapped types#111

Merged
pan-kot merged 1 commit intocloudscape-design:mainfrom
bmv437:feature/support-mapped-types
Mar 10, 2026
Merged

feat: add support for mapped types#111
pan-kot merged 1 commit intocloudscape-design:mainfrom
bmv437:feature/support-mapped-types

Conversation

@bmv437
Copy link
Contributor

@bmv437 bmv437 commented Mar 5, 2026

Issue #, if available: AWSUI-61054

Description of changes:

Motivation

The documenter crashes when a component interface uses a mapped type (e.g. { [name in IconProps.Name]?: ReactNode }), because mapped type members are synthetic symbols and getDeclarations() returns no usable property node. This blocks replacing 140+ hand-listed properties in IconProviderProps.Icons with a single mapped type (AWSUI-61054).

Changes

  • Add tryExtractDeclaration and isOptionalSymbol helpers to type-utils.ts for handling synthetic symbols from mapped types
  • Update extractor.ts and object-definition.ts to gracefully handle properties that lack PropertySignature/PropertyDeclaration nodes, falling back to checker.getTypeOfSymbolAtLocation() and symbol flag checks
  • Add test fixtures and tests covering mapped types via union constraint, Record<K,V>, and inline mapped types

Testing

  • New mapped-types.test.ts passes which covers property names, types, and optionality.
  • All existing tests pass with no regressions
  • Smoke-tested against the components repo with IconProviderProps.Icons converted to a mapped type, and documenter output is identical to the manually listed version

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@bmv437 bmv437 requested a review from a team as a code owner March 5, 2026 20:27
@bmv437 bmv437 requested review from SpyZzey and removed request for a team March 5, 2026 20:27
@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.38%. Comparing base (c76c5a2) to head (ddc761c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #111      +/-   ##
==========================================
+ Coverage   96.75%   97.38%   +0.62%     
==========================================
  Files          11       11              
  Lines         864      918      +54     
  Branches      290      294       +4     
==========================================
+ Hits          836      894      +58     
+ Misses         28       24       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +151 to +153
type = checker.getTypeOfSymbolAtLocation(value, namespaceDeclaration!);
rawTypeNode = undefined;
description = { text: undefined, tags: [] };
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a test that covers these lines (for when declaration is undefined/null)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just pushed changes that add the missing coverage.

@bmv437 bmv437 force-pushed the feature/support-mapped-types branch from e5092e5 to ddc761c Compare March 6, 2026 16:07
@pan-kot pan-kot added this pull request to the merge queue Mar 10, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Mar 10, 2026
@pan-kot pan-kot added this pull request to the merge queue Mar 10, 2026
Merged via the queue into cloudscape-design:main with commit c1e8e5b Mar 10, 2026
43 checks passed
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.

3 participants