-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Lens] Get rid of giant union type #118848
Conversation
@elasticmachine merge upstream |
Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asset management LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, I didn't test manually but I think test coverage is enough here 🆗
👏 ❤️ verified it resolves the issue in the TS bump.
|
Signed-off-by: Tyler Smalley <[email protected]>
@elasticmachine merge upstream |
expected head sha didn’t match current head ref. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data visualizer type edits LGTM
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Public APIs missing exports
History
To update your PR or re-run it, just comment with: |
💔 Backport failedThe backport operation could not be completed due to the following error: The backport PRs will be merged automatically after passing CI. To backport manually run: |
(cherry picked from commit 8398d53) # Conflicts: # x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx # x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts # x-pack/plugins/lens/public/indexpattern_datasource/utils.ts
# Backport This will backport the following commits from `main` to `7.17`: - [[Lens] Get rid of giant union type (#118848)](#118848) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Joe Reuter","email":"[email protected]"},"sourceCommit":{"committedDate":"2021-11-19T12:00:35Z","message":"[Lens] Get rid of giant union type (#118848)","sha":"8398d53da4542c0673861d07ce565515318114ea","branchLabelMapping":{"^v8.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","Feature:Lens","backport:skip","v8.1.0"],"number":118848,"url":"https://github.com/elastic/kibana/pull/118848","mergeCommit":{"message":"[Lens] Get rid of giant union type (#118848)","sha":"8398d53da4542c0673861d07ce565515318114ea"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.1.0","labelRegex":"^v8.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/118848","number":118848,"mergeCommit":{"message":"[Lens] Get rid of giant union type (#118848)","sha":"8398d53da4542c0673861d07ce565515318114ea"}}]}] BACKPORT-->
Lens has been using a large union type of all possible column types in a lot of places. However, typescript is struggling to compute it and it's currently blocking a TS upgrade as it's "too complex to analyze".
This PR gets rid of the union type and replaces is with a generic
GenericIndexPatternColumn
type which doesn't allow to access the specific params of the various columns directly. In places where this is necessary, the newly introduced helperisColumnOfType<SpecificColumnType>('specificOperationType', column)
can be used as a type guard.Most of the changes in this PR are caused by tests because we can't just provide matching params now - instead, the literal object has to be casted to the right type manually.
This change shouldn't hurt our type safety much in practice - the biggest impact is that the explicit
isColumnOfType
has to be used now instead of implicit type guards andcolumn.operationType
checks.