diff --git a/fixtures/components/highcharts/chart/index.tsx b/fixtures/components/highcharts/chart/index.tsx new file mode 100644 index 0000000..fe32ed2 --- /dev/null +++ b/fixtures/components/highcharts/chart/index.tsx @@ -0,0 +1,32 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +import * as React from 'react'; +import { NonCancelableEventHandler } from '../../internal/events'; + +class Highcharts {} + +namespace Highcharts { + export interface Point { + x: number; + y: number; + } + + export type Group = readonly Point[]; +} + +export interface ChartProps { + callback(highcharts: Highcharts): void; + onHighlight?: NonCancelableEventHandler<{ point: Highcharts.Point; group: Highcharts.Group }>; +} + +/** + * Chart description + */ +export default function Chart({ onHighlight }: ChartProps) { + return ( + +
onHighlight?.({ detail: { point: { x: 0, y: 0 } } })}>
+ + ); +} diff --git a/fixtures/components/highcharts/tsconfig.json b/fixtures/components/highcharts/tsconfig.json new file mode 100644 index 0000000..8afdfb3 --- /dev/null +++ b/fixtures/components/highcharts/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.json", + "include": ["./**/*.tsx"] +} diff --git a/src/components/object-definition.ts b/src/components/object-definition.ts index 52e10de..1737eff 100644 --- a/src/components/object-definition.ts +++ b/src/components/object-definition.ts @@ -27,6 +27,7 @@ export function getObjectDefinition( realType.flags & ts.TypeFlags.Number || isArrayType(realType) || realTypeName === 'HTMLElement' || + realTypeName.split('.')[0] === 'Highcharts' || type === 'React.ReactNode' ) { // do not expand built-in Javascript methods or primitive values diff --git a/test/components/__snapshots__/highcharts.test.ts.snap b/test/components/__snapshots__/highcharts.test.ts.snap new file mode 100644 index 0000000..26afbcc --- /dev/null +++ b/test/components/__snapshots__/highcharts.test.ts.snap @@ -0,0 +1,66 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`should not expand highcharts types 1`] = ` +[ + { + "dashCaseName": "chart", + "description": "Chart description", + "events": [ + { + "cancelable": false, + "deprecatedTag": undefined, + "description": undefined, + "detailInlineType": { + "name": "{ point: Highcharts.Point; group: Highcharts.Group; }", + "properties": [ + { + "name": "group", + "optional": false, + "type": "Highcharts.Group", + }, + { + "name": "point", + "optional": false, + "type": "Highcharts.Point", + }, + ], + "type": "object", + }, + "detailType": "{ point: Highcharts.Point; group: Highcharts.Group; }", + "name": "onHighlight", + "systemTags": undefined, + }, + ], + "functions": [], + "name": "Chart", + "properties": [ + { + "analyticsTag": undefined, + "defaultValue": undefined, + "deprecatedTag": undefined, + "description": undefined, + "i18nTag": undefined, + "inlineType": { + "name": "(highcharts: Highcharts) => void", + "parameters": [ + { + "name": "highcharts", + "type": "Highcharts", + }, + ], + "returnType": "void", + "type": "function", + }, + "name": "callback", + "optional": false, + "systemTags": undefined, + "type": "(highcharts: Highcharts) => void", + "visualRefreshTag": undefined, + }, + ], + "regions": [], + "releaseStatus": "stable", + "systemTags": undefined, + }, +] +`; diff --git a/test/components/highcharts.test.ts b/test/components/highcharts.test.ts new file mode 100644 index 0000000..4370550 --- /dev/null +++ b/test/components/highcharts.test.ts @@ -0,0 +1,10 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { expect, test } from 'vitest'; +import { buildProject } from './test-helpers'; + +test('should not expand highcharts types', () => { + const result = buildProject('highcharts'); + expect(result).toMatchSnapshot(); +});