Skip to content

Optimize EditorConfigProvider merging logic#40250

Merged
timroes merged 2 commits intoelastic:masterfrom
timroes:config-provider-merging
Jul 4, 2019
Merged

Optimize EditorConfigProvider merging logic#40250
timroes merged 2 commits intoelastic:masterfrom
timroes:config-provider-merging

Conversation

@timroes
Copy link
Contributor

@timroes timroes commented Jul 3, 2019

Summary

This optimized the EditorConfigProvider code a bit (there is no chance in functionality). This will be needed to update to upgrade TypeScript to the next version, because the old could would fail in the newer version (because of some "too broad typings").

Review tip: Best to be reviewed with white spaces ignored setting.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@timroes timroes added chore Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.3.0 labels Jul 3, 2019
@timroes timroes requested review from jen-huang and spalger July 3, 2019 11:38
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

merged: EditorParamConfig,
paramName: string
): { fixedValue?: any; base?: number } {
): { fixedValue: unknown } | { base: number } | {} {
Copy link
Contributor Author

@timroes timroes Jul 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ We know this method is returning either of those, so we use a union type here instead, which makes more sense.

merged: EditorParamConfig,
paramName: string
): { timeBase?: string; default?: string } {
): { timeBase: string; default: string } {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ The problem here was, that the method could from it's types return an object without default, that would then legibly fail (in newer TS versions) later on, because TS detects correctly, that a TimeIntervalParam needs this, so this merge method must return it. In fact it also does, if we remove the last if check for isTimeBaseParam(current) which is anyway redundant, since we know that current is a TimeIntervalParam (it's the type of the parameter).

}

if (this.isTimeBaseParam(current)) {
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ I removed the redundant try-catch blocks, that were just rethrowing the caught error.

@timroes timroes mentioned this pull request Jul 3, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@spalger spalger added the v7.4.0 label Jul 3, 2019
Copy link
Contributor

@jen-huang jen-huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, tested locally on rollup index pattern and hybrid index pattern.

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@timroes timroes merged commit 403a05c into elastic:master Jul 4, 2019
@timroes timroes deleted the config-provider-merging branch July 4, 2019 10:08
timroes pushed a commit to timroes/kibana that referenced this pull request Jul 4, 2019
timroes pushed a commit to timroes/kibana that referenced this pull request Jul 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v7.3.0 v7.4.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants