Skip to content

Conversation

@Who-is-PS
Copy link
Member

Description

Fixed an issue where CodeEditorProps.Language type values were incorrectly formatted in generated component definitions. The LiteralUnion<BuiltInLanguage, string> type was not properly recognized as a primitive string type, causing language values to appear as "\"javascript\"" instead of "javascript" in the documentation.

Related links, issue #, if available:
AWSUI-61340

How has this been tested?

  • Added comprehensive unit tests in src/code-editor/__tests__/language-selector.test.tsx
  • Verified built-in languages (e.g., 'javascript') display correctly
  • Verified custom languages (e.g., 'partiql') work with labels
  • Confirmed LiteralUnion type assignments work without TypeScript errors
  • Updated and verified snapshot tests pass with corrected format
  • Tested that lib/components-definitions/components/code-editor.js now generates clean values
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

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

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.24%. Comparing base (b70a61d) to head (0e8212e).
⚠️ Report is 33 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4009      +/-   ##
==========================================
+ Coverage   97.17%   97.24%   +0.07%     
==========================================
  Files         856      859       +3     
  Lines       25241    25389     +148     
  Branches     8938     9051     +113     
==========================================
+ Hits        24527    24690     +163     
+ Misses        708      652      -56     
- Partials        6       47      +41     

☔ 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.

Copy link
Member

@gethinwebster gethinwebster left a comment

Choose a reason for hiding this comment

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

I think that the current behavior is correct/expected. And so this should probably be handled in the website instead of the documenter. Or, maybe the documenter needs to create two different types of unions: string-union and literal-union or something like that. With the current proposed change, we're losing information about the underlying types

"inlineType": {
"name": "InputProps.Step",
"type": "union",
"values": [
Copy link
Member

Choose a reason for hiding this comment

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

Based on this example, I'm not sure the previous behavior was actually incorrect. In this case, the correct type is number | "any", which is no longer preserved correctly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated the patch to be more targeted, it now only treats true LiteralUnion
patterns (those with the { _?: never } marker) as string unions, while preserving mixed unions like number | 'any' with their full type information.

@@ -0,0 +1,40 @@
diff --git a/node_modules/@cloudscape-design/documenter/components/object-definition.js b/node_modules/@cloudscape-design/documenter/components/object-definition.js
Copy link
Member

Choose a reason for hiding this comment

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

I guess this file shouldn't be here?

"xl",
"xxl",
"xxxl",
"BoxProps.Spacing",
Copy link
Member

Choose a reason for hiding this comment

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

this one is still incorrect: "s", "m" etc. are strings, BoxProps.Spacing is a type, but all look the same in the new output

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