mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `7.17`: - [[TypeScript] Upgrade to 4.5.3 (#120812)](https://github.com/elastic/kibana/pull/120812) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Brian Seeders","email":"brian.seeders@elastic.co"},"sourceCommit":{"committedDate":"2021-12-13T17:54:17Z","message":"[TypeScript] Upgrade to 4.5.3 (#120812)","sha":"16af3e612d27bd3608787a3daab121d648787f67","branchLabelMapping":{"^v8.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Operations","Feature:Embedding","Team:APM","release_note:skip","Feature:CI","backport:skip","Team:Fleet","v8.1.0"],"number":120812,"url":"https://github.com/elastic/kibana/pull/120812","mergeCommit":{"message":"[TypeScript] Upgrade to 4.5.3 (#120812)","sha":"16af3e612d27bd3608787a3daab121d648787f67"}},"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/120812","number":120812,"mergeCommit":{"message":"[TypeScript] Upgrade to 4.5.3 (#120812)","sha":"16af3e612d27bd3608787a3daab121d648787f67"}}]}] BACKPORT--> Co-authored-by: Brian Seeders <brian.seeders@elastic.co>
This commit is contained in:
parent
16434197f7
commit
6f5ea2c428
24 changed files with 38 additions and 69 deletions
|
@ -83,7 +83,7 @@
|
|||
"**/react-syntax-highlighter": "^15.3.1",
|
||||
"**/recursive-readdir/minimatch": "^3.1.2",
|
||||
"**/remark-parse/trim": "1.0.1",
|
||||
"**/typescript": "4.3.5",
|
||||
"**/typescript": "4.5.3",
|
||||
"**/underscore": "^1.13.1",
|
||||
"globby/fast-glob": "3.2.7"
|
||||
},
|
||||
|
@ -547,7 +547,7 @@
|
|||
"@types/jquery": "^3.3.31",
|
||||
"@types/js-search": "^1.4.0",
|
||||
"@types/js-yaml": "^3.11.1",
|
||||
"@types/jsdom": "^16.2.3",
|
||||
"@types/jsdom": "^16.2.13",
|
||||
"@types/json-stable-stringify": "^1.0.32",
|
||||
"@types/json5": "^2.2.0",
|
||||
"@types/license-checker": "15.0.0",
|
||||
|
@ -811,7 +811,7 @@
|
|||
"ts-loader": "^7.0.5",
|
||||
"ts-morph": "^11.0.0",
|
||||
"tsd": "^0.13.1",
|
||||
"typescript": "4.3.5",
|
||||
"typescript": "4.5.3",
|
||||
"unlazy-loader": "^0.1.3",
|
||||
"url-loader": "^2.2.0",
|
||||
"val-loader": "^1.1.1",
|
||||
|
|
|
@ -46,7 +46,11 @@ function getOptions(context = {}, childContextTypes = {}, props = {}) {
|
|||
/**
|
||||
* When using @kbn/i18n `injectI18n` on components, props.intl is required.
|
||||
*/
|
||||
function nodeWithIntlProp<T>(node: ReactElement<T>): ReactElement<T & { intl: InjectedIntl }> {
|
||||
// This function is exported solely to fix the types output in TS 4.5.2, likely a bug
|
||||
// Otherwise, InjectedIntl is missing from the output
|
||||
export function nodeWithIntlProp<T>(
|
||||
node: ReactElement<T>
|
||||
): ReactElement<T & { intl: InjectedIntl }> {
|
||||
return React.cloneElement<any>(node, { intl });
|
||||
}
|
||||
|
||||
|
|
|
@ -44,11 +44,9 @@ describe('RecentlyAccessed#start()', () => {
|
|||
let originalLocalStorage: Storage;
|
||||
beforeAll(() => {
|
||||
originalLocalStorage = window.localStorage;
|
||||
// @ts-expect-error
|
||||
window.localStorage = new LocalStorageMock();
|
||||
});
|
||||
beforeEach(() => localStorage.clear());
|
||||
// @ts-expect-error
|
||||
afterAll(() => (window.localStorage = originalLocalStorage));
|
||||
|
||||
const getStart = async () => {
|
||||
|
|
|
@ -117,10 +117,10 @@ export async function deleteEmptyFolders(
|
|||
|
||||
// Delete empty is used to gather all the empty folders and
|
||||
// then we use del to actually delete them
|
||||
const emptyFoldersList = await deleteEmpty(rootFolderPath, {
|
||||
const emptyFoldersList = (await deleteEmpty(rootFolderPath, {
|
||||
// @ts-expect-error DT package has incorrect types https://github.com/jonschlinkert/delete-empty/blob/6ae34547663e6845c3c98b184c606fa90ef79c0a/index.js#L160
|
||||
dryRun: true,
|
||||
});
|
||||
})) as unknown as string[]; // DT package has incorrect types
|
||||
|
||||
const foldersToDelete = emptyFoldersList.filter((folderToDelete) => {
|
||||
return !foldersToKeep.some((folderToKeep) => folderToDelete.includes(folderToKeep));
|
||||
|
|
|
@ -86,6 +86,7 @@ export const EditorMenu = ({ dashboardContainer, createNewVisType }: Props) => {
|
|||
const factories = embeddable
|
||||
? Array.from(embeddable.getEmbeddableFactories()).filter(
|
||||
({ type, isEditable, canCreateNew, isContainerType }) =>
|
||||
// @ts-expect-error ts 4.5 upgrade
|
||||
isEditable() && !isContainerType && canCreateNew() && type !== 'visualization'
|
||||
)
|
||||
: [];
|
||||
|
|
|
@ -130,6 +130,7 @@ export class AddPanelFlyout extends React.Component<Props, State> {
|
|||
private getCreateMenuItems(): ReactElement[] {
|
||||
return [...this.props.getAllFactories()]
|
||||
.filter(
|
||||
// @ts-expect-error ts 4.5 upgrade
|
||||
(factory) => factory.isEditable() && !factory.isContainerType && factory.canCreateNew()
|
||||
)
|
||||
.map((factory) => (
|
||||
|
|
|
@ -41,8 +41,6 @@ export function handleKibanaStats(
|
|||
const { kibana, kibana_stats: kibanaStats, ...plugins } = response;
|
||||
|
||||
const os = {
|
||||
platform: 'unknown',
|
||||
platformRelease: 'unknown',
|
||||
...kibanaStats.os,
|
||||
};
|
||||
const formattedOsStats = Object.entries(os).reduce((acc, [key, value]) => {
|
||||
|
|
|
@ -7,23 +7,21 @@
|
|||
"node_modules/@kbn/*",
|
||||
"bazel-out/darwin-fastbuild/bin/packages/kbn-*",
|
||||
"bazel-out/k8-fastbuild/bin/packages/kbn-*",
|
||||
"bazel-out/x64_windows-fastbuild/bin/packages/kbn-*",
|
||||
"bazel-out/x64_windows-fastbuild/bin/packages/kbn-*"
|
||||
],
|
||||
// Allows for importing from `kibana` package for the exported types.
|
||||
"kibana": ["./kibana"],
|
||||
"kibana/public": ["src/core/public"],
|
||||
"kibana/server": ["src/core/server"],
|
||||
"@emotion/core": [
|
||||
"typings/@emotion"
|
||||
],
|
||||
"resize-observer-polyfill": [
|
||||
"typings/resize-observer-polyfill"
|
||||
]
|
||||
"@emotion/core": ["typings/@emotion"],
|
||||
"resize-observer-polyfill": ["typings/resize-observer-polyfill"]
|
||||
},
|
||||
// Support .tsx files and transform JSX into calls to React.createElement
|
||||
"jsx": "react",
|
||||
// Enables all strict type checking options.
|
||||
"strict": true,
|
||||
// for now, don't use unknown in catch
|
||||
"useUnknownInCatchVariables": false,
|
||||
// All TS projects should be composite and only include the files they select, and ref the files outside of the project
|
||||
"composite": true,
|
||||
// save information about the project graph on disk
|
||||
|
|
|
@ -130,7 +130,6 @@ export function UXAppRoot({
|
|||
services={{ ...core, ...plugins, embeddable, data }}
|
||||
>
|
||||
<i18nCore.Context>
|
||||
{/* @ts-expect-error Type instantiation is excessively deep */}
|
||||
<RouterProvider history={history} router={uxRouter}>
|
||||
<InspectorContextProvider>
|
||||
<UrlParamsProvider>
|
||||
|
|
|
@ -121,7 +121,6 @@ export function TimeComparison() {
|
|||
const { isSmall } = useBreakpoints();
|
||||
const {
|
||||
query: { rangeFrom, rangeTo },
|
||||
// @ts-expect-error Type instantiation is excessively deep and possibly infinite.
|
||||
} = useApmParams('/services', '/backends/*', '/services/{serviceName}');
|
||||
|
||||
const { exactStart, exactEnd } = useTimeRange({
|
||||
|
|
|
@ -43,7 +43,7 @@ export async function getServicesDetailedStatistics({
|
|||
getServiceTransactionDetailedStatistics(commonProps),
|
||||
offset
|
||||
? getServiceTransactionDetailedStatistics({ ...commonProps, offset })
|
||||
: {},
|
||||
: Promise.resolve({}),
|
||||
]);
|
||||
|
||||
return { currentPeriod, previousPeriod };
|
||||
|
|
|
@ -230,7 +230,7 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
|
|||
type: string,
|
||||
id: string,
|
||||
attributes: Partial<T>,
|
||||
options?: SavedObjectsUpdateOptions
|
||||
options?: SavedObjectsUpdateOptions<T>
|
||||
) {
|
||||
if (!this.options.service.isRegistered(type)) {
|
||||
return await this.options.baseClient.update(type, id, attributes, options);
|
||||
|
|
|
@ -24,7 +24,6 @@ import type {
|
|||
GetFullAgentPolicyRequestSchema,
|
||||
FleetRequestHandler,
|
||||
} from '../../types';
|
||||
import type { AgentPolicy, NewPackagePolicy } from '../../types';
|
||||
import { FLEET_SYSTEM_PACKAGE } from '../../../common';
|
||||
import type {
|
||||
GetAgentPoliciesResponse,
|
||||
|
@ -113,10 +112,7 @@ export const createAgentPolicyHandler: RequestHandler<
|
|||
|
||||
try {
|
||||
// eslint-disable-next-line prefer-const
|
||||
let [agentPolicy, newSysPackagePolicy] = await Promise.all<
|
||||
AgentPolicy,
|
||||
NewPackagePolicy | undefined
|
||||
>([
|
||||
let [agentPolicy, newSysPackagePolicy] = await Promise.all([
|
||||
agentPolicyService.create(soClient, esClient, request.body, {
|
||||
user,
|
||||
}),
|
||||
|
|
|
@ -53,7 +53,7 @@ export class AttributionControl extends Component<Props, State> {
|
|||
return;
|
||||
}
|
||||
|
||||
const uniqueAttributions = [];
|
||||
const uniqueAttributions: Attribution[] = [];
|
||||
for (let i = 0; i < attributions.length; i++) {
|
||||
for (let j = 0; j < attributions[i].length; j++) {
|
||||
const testAttr = attributions[i][j];
|
||||
|
|
|
@ -145,7 +145,9 @@ export class ReportingCsvPanelAction implements ActionDefinition<ActionContext>
|
|||
});
|
||||
|
||||
// Hack for IE11 Support
|
||||
// @ts-expect-error
|
||||
if (window.navigator.msSaveOrOpenBlob) {
|
||||
// @ts-expect-error
|
||||
return window.navigator.msSaveOrOpenBlob(blob, download);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,9 @@ export const AutoDownload: React.FC<AutoDownloadProps> = ({ blob, name, onDownlo
|
|||
|
||||
useEffect(() => {
|
||||
if (blob && anchorRef?.current) {
|
||||
// @ts-expect-error
|
||||
if (typeof window.navigator.msSaveOrOpenBlob === 'function') {
|
||||
// @ts-expect-error
|
||||
window.navigator.msSaveBlob(blob);
|
||||
} else {
|
||||
const objectURL = window.URL.createObjectURL(blob);
|
||||
|
|
|
@ -81,7 +81,6 @@ const AnomaliesHostTableComponent: React.FC<AnomaliesHostTableProps> = ({
|
|||
<BasicTable
|
||||
// @ts-expect-error the Columns<T, U> type is not as specific as EUI's...
|
||||
columns={columns}
|
||||
// @ts-expect-error ...which leads to `networks` not "matching" the columns
|
||||
items={hosts}
|
||||
pagination={pagination}
|
||||
sorting={sorting}
|
||||
|
|
|
@ -71,7 +71,6 @@ const AnomaliesNetworkTableComponent: React.FC<AnomaliesNetworkTableProps> = ({
|
|||
<BasicTable
|
||||
// @ts-expect-error the Columns<T, U> type is not as specific as EUI's...
|
||||
columns={columns}
|
||||
// @ts-expect-error ...which leads to `networks` not "matching" the columns
|
||||
items={networks}
|
||||
pagination={pagination}
|
||||
sorting={sorting}
|
||||
|
|
|
@ -7,35 +7,11 @@
|
|||
|
||||
import { scaleLog } from 'd3-scale';
|
||||
|
||||
// Types are from: https://github.com/Microsoft/TypeScript/issues/21309
|
||||
// TODO: Once this is no longer an experimental web API, remove these below
|
||||
// as they should be Typed by TypeScript
|
||||
type RequestIdleCallbackHandle = number;
|
||||
interface RequestIdleCallbackOptions {
|
||||
timeout: number;
|
||||
}
|
||||
interface RequestIdleCallbackDeadline {
|
||||
readonly didTimeout: boolean;
|
||||
timeRemaining: () => number;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
requestIdleCallback: (
|
||||
callback: (deadline: RequestIdleCallbackDeadline) => void,
|
||||
opts?: RequestIdleCallbackOptions
|
||||
) => RequestIdleCallbackHandle;
|
||||
cancelIdleCallback: (handle: RequestIdleCallbackHandle) => void;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Polyfill is from: https://developers.google.com/web/updates/2015/08/using-requestidlecallback
|
||||
* This is for Safari 12.1.2 and IE-11
|
||||
*/
|
||||
export const polyFillRequestIdleCallback = (
|
||||
callback: (deadline: RequestIdleCallbackDeadline) => void
|
||||
) => {
|
||||
export const polyFillRequestIdleCallback = (callback: IdleRequestCallback) => {
|
||||
const start = Date.now();
|
||||
return setTimeout(() => {
|
||||
callback({
|
||||
|
@ -59,8 +35,8 @@ export const polyFillRequestIdleCallback = (
|
|||
* this and all usages. Otherwise, just remove this note
|
||||
*/
|
||||
export const requestIdleCallbackViaScheduler = (
|
||||
callback: (deadline: RequestIdleCallbackDeadline) => void,
|
||||
opts?: RequestIdleCallbackOptions
|
||||
callback: IdleRequestCallback,
|
||||
opts?: IdleRequestOptions
|
||||
) => {
|
||||
if ('requestIdleCallback' in window) {
|
||||
window.requestIdleCallback(callback, opts);
|
||||
|
|
|
@ -478,6 +478,7 @@ describe('Detections Rules API', () => {
|
|||
name: 'fileToImport',
|
||||
size: 89,
|
||||
type: 'json',
|
||||
webkitRelativePath: '/webkitRelativePath',
|
||||
arrayBuffer: jest.fn(),
|
||||
slice: jest.fn(),
|
||||
stream: jest.fn(),
|
||||
|
|
|
@ -1202,10 +1202,7 @@ export const mockSavedObject = {
|
|||
type: 'siem-ui-timeline',
|
||||
id: '79deb4c0-6bc1-11ea-a90b-f5341fb7a189',
|
||||
attributes: {
|
||||
savedQueryId: null,
|
||||
|
||||
status: 'immutable',
|
||||
|
||||
excludedRowRendererIds: [],
|
||||
...mockGetTemplateTimelineValue,
|
||||
},
|
||||
|
|
|
@ -128,7 +128,6 @@ export const ExpandedRowMessagesPane: React.FC<Props> = ({ transformId }) => {
|
|||
page = { index: 0, size: 10 },
|
||||
}: {
|
||||
page?: { index: number; size: number };
|
||||
sort?: { field: string; direction: string };
|
||||
}) => {
|
||||
const { index, size } = page;
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ export async function getRuleData(
|
|||
const loadedRule: ResolvedRule = await resolveRule(ruleId);
|
||||
setAlert(loadedRule);
|
||||
|
||||
const [loadedAlertType, loadedActionTypes] = await Promise.all<AlertType, ActionType[]>([
|
||||
const [loadedAlertType, loadedActionTypes] = await Promise.all([
|
||||
loadAlertTypes()
|
||||
.then((types) => types.find((type) => type.id === loadedRule.alertTypeId))
|
||||
.then(throwIfAbsent(`Invalid Rule Type: ${loadedRule.alertTypeId}`)),
|
||||
|
|
16
yarn.lock
16
yarn.lock
|
@ -5868,10 +5868,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.12.1.tgz#5c6f4a1eabca84792fbd916f0cb40847f123c656"
|
||||
integrity sha512-SGGAhXLHDx+PK4YLNcNGa6goPf9XRWQNAUUbffkwVGGXIxmDKWyGGL4inzq2sPmExu431Ekb9aEMn9BkPqEYFA==
|
||||
|
||||
"@types/jsdom@^16.2.3":
|
||||
version "16.2.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/jsdom/-/jsdom-16.2.3.tgz#c6feadfe0836389b27f9c911cde82cd32e91c537"
|
||||
integrity sha512-BREatezSn74rmLIDksuqGNFUTi9HNAWWQXYpFBFLK9U6wlMCO4M0QCa8CMpDsZQuqxSO9XifVLT5Q1P0vgKLqw==
|
||||
"@types/jsdom@^16.2.13":
|
||||
version "16.2.13"
|
||||
resolved "https://registry.yarnpkg.com/@types/jsdom/-/jsdom-16.2.13.tgz#126c8b7441b159d6234610a48de77b6066f1823f"
|
||||
integrity sha512-8JQCjdeAidptSsOcRWk2iTm9wCcwn9l+kRG6k5bzUacrnm1ezV4forq0kWjUih/tumAeoG+OspOvQEbbRucBTw==
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
"@types/parse5" "*"
|
||||
|
@ -27903,10 +27903,10 @@ typescript-tuple@^2.2.1:
|
|||
dependencies:
|
||||
typescript-compare "^0.0.2"
|
||||
|
||||
typescript@4.3.5, typescript@^3.3.3333, typescript@^3.5.3, typescript@^4.3.5, typescript@~4.4.2:
|
||||
version "4.3.5"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
|
||||
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==
|
||||
typescript@4.5.3, typescript@^3.3.3333, typescript@^3.5.3, typescript@^4.3.5, typescript@~4.4.2:
|
||||
version "4.5.3"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.3.tgz#afaa858e68c7103317d89eb90c5d8906268d353c"
|
||||
integrity sha512-eVYaEHALSt+s9LbvgEv4Ef+Tdq7hBiIZgii12xXJnukryt3pMgJf6aKhoCZ3FWQsu6sydEnkg11fYXLzhLBjeQ==
|
||||
|
||||
ua-parser-js@^0.7.18:
|
||||
version "0.7.24"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue