mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
## Summary Part of https://github.com/elastic/kibana/issues/138222 in @types/react@18 types https://github.com/DefinitelyTyped/DefinitelyTyped/pull/56210. This PR addresses a bunch of remaining fixes **(hopefully the last mass ping PR like this)** The most common are: ### 1 Objects are no longer considered a valid ReactNode In types@17 the ReactNode typing was too soft, it allowed objects and functions being passed as ReactNode, e.g. ``` let obj: React.ReactNode = {}; let func: React.ReactNode = () => {}; ``` This was by mistake, and this PR mutes most of such cases by simply casting to a `string` or `ReactNode`. In some cases, it is worth to follow up and address the raised issues in a better way (see in comments) ```diff function MyComponent() { const error: string | Error = 'Error' return ( <div> - {error} + {error as string} </div> ) } ``` Most common problems are related to rendering errors, where it could be `string | Error` object rendered directly as a ReactNode. Most often it is related to alerting framework: ``` export interface RuleFormParamsErrors { [key: string]: string | string[] | RuleFormParamsErrors; } ``` Not sure if there is a better fix then casting, surely not short-term. ### 2 More `useCallback` implicit any fixes Follow up to https://github.com/elastic/kibana/pull/191659 ### 3 `EuiSelect` doesn't have a placeholder prop In a couple of places, the `placeholder` prop was removed. This is because react types were updated and `placeholder` was removed from the base HTML element, so it highlighted places where `placeholder` prop was redundant |
||
---|---|---|
.. | ||
common | ||
search | ||
search_sessions | ||
sql_search | ||
application.tsx | ||
index.scss | ||
index.ts | ||
plugin.ts | ||
search_examples.png | ||
types.ts |