Skip to content
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

[Expressions] Remove the any type usages #113477

Merged
merged 4 commits into from
Oct 4, 2021
Merged

Conversation

dokmic
Copy link
Contributor

@dokmic dokmic commented Sep 29, 2021

Summary

Removed most of the any type usages from the expressions plugin.

Checklist

For maintainers

@dokmic dokmic added review Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) v8.0.0 Team:AppServicesSv release_note:skip Skip the PR/issue when compiling release notes v7.16.0 labels Sep 29, 2021
@dokmic dokmic marked this pull request as ready for review September 30, 2021 06:36
@dokmic dokmic requested review from a team as code owners September 30, 2021 06:36
@dokmic dokmic requested a review from ppisljar September 30, 2021 06:36
Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

LGTM, code review only!

event: (event: any) => void;
hasCompatibleActions?: (event: any) => Promise<boolean>;
getRenderMode: () => RenderMode;
done(): void;
Copy link
Member

Choose a reason for hiding this comment

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

arrow functions are preferred by our style guide if i remember correctly.

Copy link
Contributor Author

@dokmic dokmic Sep 30, 2021

Choose a reason for hiding this comment

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

I think it is not. Otherwise, that should be fixed there. Starting from TS 2.6, it has stricter type checks for the functions. When we define those methods as properties, which is unsound already, we are not able to extend or implement that interface with a subtype.

The following example will throw a compilation error:

interface A {
  foo: (bar: unknown) => number;
}

const a: A = {
  foo: (bar: number) => {
    return bar;
  },
};

class B implements A {
  foo(bar: number) {
    return bar;
  }
}

But this one will not:

interface A {
  foo(bar: unknown): number;
}

const a: A = {
  foo: (bar: number) => {
    return bar;
  },
};

class B implements A {
  foo(bar: number) {
    return bar;
  }
}

At first, I have fixed that for the methods with the any. But then I have corrected them all for consistency.

@@ -110,7 +110,7 @@ export const mapColumn: ExpressionFunctionDefinition<
map((rows) => {
let type: DatatableColumnType = 'null';
for (const row of rows) {
const rowType = getType(row[id]);
const rowType = getType(row[id]) as DatatableColumnType;
Copy link
Member

Choose a reason for hiding this comment

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

should we update getType function to return correct type ?

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 string is a supertype of the DatatableColumnType . That's fine to cast it here.

@dokmic dokmic force-pushed the feature/KS-1357 branch 4 times, most recently from 245aa0c to e33b674 Compare October 1, 2021 07:49
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
expressions 1626 1646 +20

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
expressions 65 27 -38

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
expressions 122.5KB 122.6KB +96.0B
Unknown metric groups

API count

id before after diff
expressions 2072 2095 +23

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Member

@ppisljar ppisljar 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

Copy link
Contributor

@crob611 crob611 left a comment

Choose a reason for hiding this comment

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

Presentation changes look good 👍

@dokmic dokmic merged commit 0d9825d into elastic:master Oct 4, 2021
@dokmic dokmic deleted the feature/KS-1357 branch October 4, 2021 16:30
dokmic added a commit to dokmic/kibana that referenced this pull request Oct 4, 2021
* Update ESLint config to disallow usage of the any type
* Remove the any type usages from the expressions plugin
* Update plugins using expressions according to the updated public API
dokmic added a commit that referenced this pull request Oct 4, 2021
* Update ESLint config to disallow usage of the any type
* Remove the any type usages from the expressions plugin
* Update plugins using expressions according to the updated public API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) release_note:skip Skip the PR/issue when compiling release notes review v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants