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

Move PublicMethodsOf into @kbn/utility-types #46699

Closed
rudolf opened this issue Sep 26, 2019 · 4 comments
Closed

Move PublicMethodsOf into @kbn/utility-types #46699

rudolf opened this issue Sep 26, 2019 · 4 comments
Labels
Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@rudolf
Copy link
Contributor

rudolf commented Sep 26, 2019

Core uses the global PublicMethodsOf utility type in several places, we should move this to @kbn/utility-types and import it instead of using the global.

We mostly use this type to get the public contract of a class. Usually this means getting the public methods but there are a few classes which expose public properties which this helper misses.

So I propose we create a PublicContractOf helper instead:

export type PublicContractOf<T> = Pick<T, keyof T>
@rudolf rudolf added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform labels Sep 26, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@mshustov
Copy link
Contributor

mshustov commented Sep 26, 2019

+1 the current solution breaks typings, because PublicMethodsOf is src/ and in x-pack are different types.
Does it make sense to move all types from https://github.com/restrry/kibana/blob/f783d48301ff01cec7df163bea0b4adc8dd26422/typings/index.d.ts ?

@rudolf rudolf mentioned this issue Dec 6, 2019
7 tasks
@streamich
Copy link
Contributor

streamich commented Feb 15, 2020

+1, and maybe we can call it:

type PublicKeys<T> = keyof T;
type PublicContract<T> = Pick<T, PublicKeys<T>>

@streamich streamich mentioned this issue Feb 17, 2020
1 task
@rudolf
Copy link
Contributor Author

rudolf commented Dec 17, 2020

Fixed in #76785

@rudolf rudolf closed this as completed Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

4 participants