[react@18] (Part 2) fix useCallback breaking type changes#191659
Merged
Dosant merged 15 commits intoelastic:mainfrom Sep 4, 2024
Merged
[react@18] (Part 2) fix useCallback breaking type changes#191659Dosant merged 15 commits intoelastic:mainfrom
Dosant merged 15 commits intoelastic:mainfrom
Conversation
Contributor
Author
|
/ci |
Contributor
Author
|
@elasticmachine merge upstream |
achyutjhunjhunwala
approved these changes
Sep 3, 2024
Contributor
achyutjhunjhunwala
left a comment
There was a problem hiding this comment.
Infra and Logs Shared plugin changes LGTM 👍🏼
Contributor
Author
|
@elasticmachine merge upstream |
cnasikas
approved these changes
Sep 3, 2024
Member
There was a problem hiding this comment.
ResponseOps changes LGTM. I left some comments (#191659 (comment) and #191659 (comment)) on how to fix some of the any.
andrew-goldstein
approved these changes
Sep 3, 2024
logeekal
approved these changes
Sep 3, 2024
| const render = useCallback( | ||
| (dataProvider, _, snapshot) => | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (dataProvider: any, _: any, snapshot: any) => |
| const render = useCallback( | ||
| (_props, _provided, snapshot) => | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (_props: any, _provided: any, snapshot: any) => |
ilyannn
approved these changes
Sep 3, 2024
Contributor
|
Scalability LGTM |
…k-any-2 # Conflicts: # packages/kbn-unified-data-table/src/components/data_table.tsx
angorayc
approved these changes
Sep 4, 2024
sphilipse
approved these changes
Sep 4, 2024
Contributor
Author
|
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
This was referenced Sep 5, 2024
Closed
Dosant
added a commit
that referenced
this pull request
Sep 12, 2024
## Summary Part of #138222 in @types/react@18 types DefinitelyTyped/DefinitelyTyped#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 #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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a prep for #138222 and follow up to #182344. These are post-merge leftovers and new instances from the previous run
In React@18 useCallback types have changed that introducing breaking changes:
DefinitelyTyped/DefinitelyTyped#46691
Found potential issues using:
https://github.com/eps1lon/types-react-codemod?tab=readme-ov-file#usecallback-implicit-any
I tried to do my best to fix the type where possible, but there are some complicated cases where I kept
anyafter some struggling. Please feel free to push improvements directly.