[Lens] Get rid of giant union type#118848
Conversation
|
@elasticmachine merge upstream |
|
Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors) |
patrykkopycinski
left a comment
There was a problem hiding this comment.
Asset management LGTM
mbondyra
left a comment
There was a problem hiding this comment.
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 <tyler.smalley@elastic.co>
|
@elasticmachine merge upstream |
|
expected head sha didn’t match current head ref. |
peteharverson
left a comment
There was a problem hiding this comment.
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":"johannes.reuter@elastic.co"},"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
GenericIndexPatternColumntype 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
isColumnOfTypehas to be used now instead of implicit type guards andcolumn.operationTypechecks.