Skip to content

Commit

Permalink
chore(wiki): add a mention about typing icons (#8390)
Browse files Browse the repository at this point in the history
  • Loading branch information
weronikaolejniczak authored Mar 6, 2025
1 parent ec284b8 commit 3ad4d7d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions wiki/consuming-eui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,24 @@ appendIconComponentCache({
});
```

#### Usage with TypeScript

To ensure the icons are correctly typed, you need to declare a module for the icon assets. This declaration will allow TypeScript to understand the expected type of the icon components.

```ts
// .d.ts
declare module "@elastic/eui/es/components/icon/assets/*" {
import * as React from 'react';
import type { SVGProps } from 'react';
interface SVGRProps {
title?: string;
titleId?: string;
}
export const icon: ({ title, titleId, ...props }: SVGProps<SVGSVGElement> & SVGRProps) => React.JSX.Element;
export {};
}
```

## Using the `test-env` build

EUI provides a separate babel-transformed and partially mocked commonjs build for testing environments in consuming projects. The output is identical to that of `lib/`, but has transformed async functions and dynamic import statements, and also applies some useful mocks. This build mainly targets Kibana's Jest environment, but may be helpful for testing environments in other projects.
Expand Down

0 comments on commit 3ad4d7d

Please sign in to comment.