-
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
[Fleet] Use type-only imports where possible #92979
Conversation
@elasticmachine merge upstream |
Pinging @elastic/fleet (Team:Fleet) |
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.
Nice improvement 👍🏻 Spot checked the files but not all of them.
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @jfsiii |
* master: (199 commits) Convert Canvas docs to MDX for use in Elastic Docs (elastic#91969) [Bazel] More resilient Workspace Status (elastic#93244) [Discover] Change icon of saved search in open search panel and embeddable selection (elastic#93001) [Workplace Search] Role Mappings to Kibana (elastic#93123) [Fleet] Use type-only imports where possible (elastic#92979) [Lens] Set pie chart slices sorted clockwise (elastic#92617) Remove ms label from CPU load on status page (elastic#92836) [App Search] Migrate Create Meta Engine View (elastic#92127) [Time to Visualize] Disable Visualize URL Tracker When Linked to OriginatingApp (elastic#92917) [ILM] Allow multiple searchable snapshot actions (elastic#92789) Improve consistency for display of management items (elastic#92694) skip flaky suite (elastic#93152) skip flaky suite (elastic#93152) [ILM] Refactor edit_policy client integration tests into separate feature files (elastic#92826) Add developer documentation about the building blocks we offer plugin developers (elastic#92743) [Security Solution] Case ui enhancement (elastic#91863) [Security Solution] [Detections] Updates warning message when no indices match provided index patterns (elastic#93094) Collect agent telemetry even when fleet server is disabled. (elastic#93198) [Lens] Fix runtime validation error message (elastic#93195) [Lens] Remove warning about ordinal x-domain (elastic#93049) ...
## Summary Use [type-only `import`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) to differentiate between runtime values and (erasable) TS types. <img width="1499" alt="Screen Shot 2021-02-27 at 6 34 46 PM" src="https://user-images.githubusercontent.com/57655/109403323-84e32c80-792a-11eb-94b7-854d0e5c3e99.png"> Allows Babel and `tsc` to make some optimizations since it can be sure what can be erased. It can also be helpful in situations like below which highlights that even though `KibanaAssetType` and `KibanaSavedObjectType` are named a certain way and from `common/types`, they are JS values _not_ TS types. They are `enum`s which means they are JS objects at runtime; not eliminated at runtime. https://github.com/elastic/kibana/blob/d92a1a08d89accc2fa303b1355a9e222f9b6d090/x-pack/plugins/fleet/common/types/models/epm.ts#L41-L63 # Conflicts: # x-pack/plugins/fleet/server/services/index.ts
…94464) ## Summary Use the [`consistent-type-imports` lint rule ](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-imports.md) to use `import type ...` where possible Code-only changes like this were recently added in #92979, but it was a more manual process. This PR adds an autofixable lint rule which will keep the changes up-to-date and Just Work ™️
…94464) (#94868) ## Summary Use the [`consistent-type-imports` lint rule ](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-imports.md) to use `import type ...` where possible Code-only changes like this were recently added in #92979, but it was a more manual process. This PR adds an autofixable lint rule which will keep the changes up-to-date and Just Work ™️ # Conflicts: # x-pack/plugins/fleet/server/services/agents/crud.ts # x-pack/plugins/fleet/server/services/artifacts/artifacts.ts # x-pack/plugins/fleet/server/services/artifacts/mappings.ts # x-pack/plugins/fleet/server/services/artifacts/mocks.ts # x-pack/plugins/fleet/server/services/index.ts
Summary
Use type-only
import
to differentiate between runtime values and (erasable) TS types.Allows Babel and
tsc
to make some optimizations since it can be sure what can be erased.It can also be helpful in situations like below which highlights that even though
KibanaAssetType
andKibanaSavedObjectType
are named a certain way and fromcommon/types
, they are JS values not TS types. They areenum
s which means they are JS objects at runtime; not eliminated at runtime.kibana/x-pack/plugins/fleet/common/types/models/epm.ts
Lines 41 to 63 in d92a1a0