Skip to content

Conversation

@pan-kot
Copy link
Member

@pan-kot pan-kot commented Aug 13, 2025

Without these changes, the documenter fails in chart-components - see: cloudscape-design/chart-components#88

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

@pan-kot pan-kot requested a review from a team as a code owner August 13, 2025 09:46
@pan-kot pan-kot requested review from georgylobko and removed request for a team August 13, 2025 09:46
@codecov
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #85   +/-   ##
=======================================
  Coverage   92.21%   92.22%           
=======================================
  Files          15       15           
  Lines         925      926    +1     
  Branches      273      274    +1     
=======================================
+ Hits          853      854    +1     
  Misses         72       72           

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

realType.flags & ts.TypeFlags.Number ||
isArrayType(realType) ||
realTypeName === 'HTMLElement' ||
realTypeName.startsWith('SVG') ||
Copy link
Member Author

Choose a reason for hiding this comment

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

The SVG elements are complex fail with the following error:

Error: Multiple declarations found for symbol: addEventListener

Having multiple function declarations is valid TS, but unsupported by documenter. There is also no reason to deep-expand native types.

Copy link
Member

Choose a reason for hiding this comment

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

Still recommend full name matches, just in case if we have any our own type "SVGIcon" or something

isArrayType(realType) ||
realTypeName === 'HTMLElement' ||
realTypeName.startsWith('SVG') ||
realTypeName.includes('Highcharts') ||
Copy link
Member Author

Choose a reason for hiding this comment

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

The Highcharts objects are complex and recursive - those fails with Max call stack exceeded error.

There is also no good reason to expand these as the customers can use Highcharts docs for these instead. Also, atm. both SVG and Highcharts objects are only present in the unofficial chart-core component, not shown in the website. We generate docs for snapshots only.

Copy link
Member

Choose a reason for hiding this comment

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

Similar comment here. Instead of includes it should be a full text. Or at least realTypeName.split('.')[0] === 'Highcharts'

Copy link
Member

@just-boris just-boris left a comment

Choose a reason for hiding this comment

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

And there should be a unit test on this, of course

realType.flags & ts.TypeFlags.Number ||
isArrayType(realType) ||
realTypeName === 'HTMLElement' ||
realTypeName.startsWith('SVG') ||
Copy link
Member

Choose a reason for hiding this comment

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

Still recommend full name matches, just in case if we have any our own type "SVGIcon" or something

isArrayType(realType) ||
realTypeName === 'HTMLElement' ||
realTypeName.startsWith('SVG') ||
realTypeName.includes('Highcharts') ||
Copy link
Member

Choose a reason for hiding this comment

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

Similar comment here. Instead of includes it should be a full text. Or at least realTypeName.split('.')[0] === 'Highcharts'

@pan-kot
Copy link
Member Author

pan-kot commented Aug 13, 2025

And there should be a unit test on this, of course

@just-boris could you recommend a test design for this one?

I attempted a snapshot test, for which I created a fixture like this:

interface ComponentProps {
  buttonRef(button: null | HTMLElement): void;
  chartRef(chart: null | SVGSVGElement): void;
}

namespace ComponentProps {
  interface Ref {
    register(button: HTMLButton, chart: SVGSVGElement): void;
  }
}

However, it generated an output that listed the SVGSVGElement type as is, w/o any changes to the code.

Edit: I managed to make the snapshot test work with fake Highcharts.Point interface.

@pan-kot pan-kot force-pushed the fix-core-documenter-snapshot branch from 8043b01 to b2e38c9 Compare August 13, 2025 10:36
@pan-kot
Copy link
Member Author

pan-kot commented Aug 13, 2025

@just-boris , @georgylobko

I made the following updates:

  1. Replaced highcharts type check with exact comparison (only need Highcharts.Point, which is present in core chart event listeners);
  2. Added snapshot test to ensure the type named Highcharts.Point is not expanded;
  3. Removed SVG check (SVG refs were inside the Highcharts.Point, we don't reference them otherwise, so not needed yet).

@pan-kot pan-kot enabled auto-merge August 13, 2025 10:37
@pan-kot pan-kot requested a review from just-boris August 13, 2025 10:38
@just-boris
Copy link
Member

SVG refs were inside the Highcharts.Point, we don't reference them otherwise, so not needed yet

Ok, good for now, approving

just-boris
just-boris previously approved these changes Aug 13, 2025
realType.flags & ts.TypeFlags.Number ||
isArrayType(realType) ||
realTypeName === 'HTMLElement' ||
realTypeName === 'Highcharts.Point' ||
Copy link
Member

Choose a reason for hiding this comment

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

To make your life simpler, I still recommend checking realTypeName.split('.')[0] only to avoid editing this check any time someone uses a new type from Highcharts

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes total sense, updated!

@pan-kot pan-kot disabled auto-merge August 13, 2025 10:55
@pan-kot pan-kot added this pull request to the merge queue Aug 13, 2025
Merged via the queue into main with commit d4cc7bf Aug 13, 2025
35 checks passed
@pan-kot pan-kot deleted the fix-core-documenter-snapshot branch August 13, 2025 12:28
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