Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion scripts/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,13 @@ const sourceFiles = Array.from(elementFilesMap.entries(), ([element, data]) => g
const elementNames = sourceFiles.map(({ fileName }) => basename(fileName, '.ts'));

function generateIndexFile(elementNames: readonly string[], extension: string): SourceFile {
const sourceLines = [...elementNames.map((elementName) => `export * from './${elementName}.js';`)];
const sourceLines = [
...elementNames.map((elementName) => `export * from './${elementName}.js';`),
// Explicit re-exports beat star exports per-name in TypeScript, so these deterministically
// resolve each component name (e.g. `SelectItem`) even if another module's `export *` chain
// re-exports a colliding name (e.g. a deprecated type from a web component package).
...elementNames.map((elementName) => `export { ${elementName} } from './${elementName}.js';`),
];

return ts.createSourceFile(
resolve(packageDir, `index.${extension}`),
Expand Down
16 changes: 16 additions & 0 deletions test/typings/SelectItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { SelectItem, type SelectItemData } from '@vaadin/react-components';
import type { SelectItem as SelectItemType } from '@vaadin/react-components/Select.js';

// `SelectItem` must resolve to the React component and work in value/JSX position.
const element = <SelectItem value="x">x</SelectItem>;

// `SelectItemData` must still work in type position (unaffected by the collision fix).
const items: SelectItemData[] = [];

// The deprecated `SelectItem` type is intentionally no longer exported from the barrel;
// `SelectItem` now refers only to the component, so using it as a type must fail to compile.
// @ts-expect-error — `SelectItem` is a value (the component) in the barrel, not a type.
let deprecated: SelectItem[];

// Escape hatch: the deprecated type is still importable directly from the Select.js subpath.
let stillWorks: SelectItemType[] = [];
Loading