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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Fixed `EuiInMemoryTable` to allow sorting on computed columns ([#2044](https://github.com/elastic/eui/pull/2044))
- Fixed TypeScript `Toast` member export ([#2052](https://github.com/elastic/eui/pull/2052))
- Fixed style of readOnly input groups via `EuiFormControlLayout` and `prepend`/`append` ([#2057](https://github.com/elastic/eui/pull/2057))
- Removed TS types from ES exports when the exported name differs from the imported one ([#2069](https://github.com/elastic/eui/pull/2069))

## [`12.0.0`](https://github.com/elastic/eui/tree/v12.0.0)

Expand Down
8 changes: 4 additions & 4 deletions scripts/babel/proptypes-from-ts-props/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ const typeDefinitionExtractors = {
case 'ImportSpecifier':
return specifier.imported.name;
case 'ExportSpecifier':
return specifier.exported.name;
return specifier.local.name;

// default:
// throw new Error(`Unable to process import specifier type ${specifier.type}`);
Expand Down Expand Up @@ -1103,9 +1103,9 @@ module.exports = function propTypesFromTypeScript({ types }) {
const specifiers = path.get('specifiers');
specifiers.forEach(specifierPath => {
if (types.isExportSpecifier(specifierPath)) {
const { node: { exported } } = specifierPath;
if (types.isIdentifier(exported)) {
const { name } = exported;
const { node: { local } } = specifierPath;
if (types.isIdentifier(local)) {
const { name } = local;
const def = typeDefinitions[name];
if (isTSType(def)) {
specifierPath.remove();
Expand Down
34 changes: 34 additions & 0 deletions scripts/babel/proptypes-from-ts-props/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2441,6 +2441,40 @@ export { Foo, A } from './foo';
expect(result.code).toBe(`export { A } from './foo';`);
});

it('removes type exports from ExportNamedDeclaration when the imported name differs from the exported one', () => {
const result = transform(
`
export { Foo as Bar, A as B } from './foo';
`,
{
...babelOptions,
plugins: [
[
'./scripts/babel/proptypes-from-ts-props',
{
fs: {
existsSync: () => true,
statSync: () => ({ isDirectory: () => false }),
readFileSync: filepath => {
if (filepath.endsWith(`${path.sep}foo`)) {
return Buffer.from(`
export const A = 5;
export type Foo = string;
`);
}

throw new Error(`Test tried to import from ${filepath}`);
}
}
}
],
]
}
);

expect(result.code).toBe(`export { A as B } from './foo';`);
});

it('removes type export statements', () => {
const result = transform(
`
Expand Down