Skip to content

Remove unexposed functions from declaration files #3709

@markov00

Description

@markov00

The generated declaration file eui.d.ts is exposing some utility functions used only for tests like takeMountedSnapshot

declare module '@elastic/eui/src/test/take_mounted_snapshot' {
	import { ReactWrapper } from 'enzyme';
	import { Component } from 'react';
	export const takeMountedSnapshot: (mountedComponent: ReactWrapper<{}, {}, Component<{}, {}, any>>) => ChildNode | null;
}

This requires to declare @types/enzyme in the deps instead of devDeps as you also noticed here: #2828

Do we really need these test utility to be exported as part of the public API?
I’m asking because this dependency can and is creating some resolution conflicts within @elastic/charts because of two different versions of @types/react. I've solved that updating reacts types here and there, but I think it can be also cleanly solved if EUI exposes only its own types.

In elastic-charts we are using to mark the dependencies we don't want in the generated files as @internals and use stripInternals in the tsconfig.json (it's something that at the moment is not documented, I don't have an idea on why it's not on the TS documentation anymore).

Some cleanup can also be possible with the other @types you have moved under deps

@chandlerprall @thompsongl

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions