mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
[TypeScript] Upgrade to 4.5.3 (#120812)
This commit is contained in:
parent
cc2715ae85
commit
16af3e612d
25 changed files with 45 additions and 67 deletions
|
@ -91,7 +91,7 @@
|
|||
"**/react-syntax-highlighter": "^15.3.1",
|
||||
"**/react-syntax-highlighter/**/highlight.js": "^10.4.1",
|
||||
"**/trim": "1.0.1",
|
||||
"**/typescript": "4.3.5",
|
||||
"**/typescript": "4.5.3",
|
||||
"**/underscore": "^1.13.1",
|
||||
"globby/fast-glob": "3.2.7"
|
||||
},
|
||||
|
@ -555,7 +555,7 @@
|
|||
"@types/js-levenshtein": "^1.1.0",
|
||||
"@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": "^0.0.30",
|
||||
"@types/kbn__ace": "link:bazel-bin/packages/kbn-ace/npm_module_types",
|
||||
|
@ -836,7 +836,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'
|
||||
)
|
||||
: [];
|
||||
|
|
|
@ -164,7 +164,10 @@ export class AttributeService<
|
|||
try {
|
||||
const newAttributes = { ...(input as ValType)[ATTRIBUTE_SERVICE_KEY] };
|
||||
newAttributes.title = props.newTitle;
|
||||
const wrappedInput = (await this.wrapAttributes(newAttributes, true)) as RefType;
|
||||
const wrappedInput = (await this.wrapAttributes(
|
||||
newAttributes,
|
||||
true
|
||||
)) as unknown as RefType;
|
||||
|
||||
// Remove unneeded attributes from the original input.
|
||||
const newInput = omit(input, ATTRIBUTE_SERVICE_KEY);
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -43,7 +43,7 @@ export async function getServicesDetailedStatistics({
|
|||
getServiceTransactionDetailedStatistics(commonProps),
|
||||
offset
|
||||
? getServiceTransactionDetailedStatistics({ ...commonProps, offset })
|
||||
: {},
|
||||
: Promise.resolve({}),
|
||||
]);
|
||||
|
||||
return { currentPeriod, previousPeriod };
|
||||
|
|
|
@ -91,7 +91,7 @@ export const EditorMenu: FC<Props> = ({ addElement }) => {
|
|||
if (embeddableInput) {
|
||||
const config = encode(embeddableInput);
|
||||
const expression = `embeddable config="${config}"
|
||||
type="${factory.type}"
|
||||
type="${factory.type}"
|
||||
| render`;
|
||||
|
||||
addElement({ expression });
|
||||
|
@ -123,6 +123,7 @@ export const EditorMenu: FC<Props> = ({ addElement }) => {
|
|||
const factories = embeddablesService
|
||||
? Array.from(embeddablesService.getEmbeddableFactories()).filter(
|
||||
({ type, isEditable, canCreateNew, isContainerType }) =>
|
||||
// @ts-expect-error ts 4.5 upgrade
|
||||
isEditable() &&
|
||||
!isContainerType &&
|
||||
canCreateNew() &&
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -23,7 +23,6 @@ import type {
|
|||
DeleteAgentPolicyRequestSchema,
|
||||
GetFullAgentPolicyRequestSchema,
|
||||
} from '../../types';
|
||||
import type { AgentPolicy, NewPackagePolicy } from '../../types';
|
||||
import { FLEET_SYSTEM_PACKAGE } from '../../../common';
|
||||
import type {
|
||||
GetAgentPoliciesResponse,
|
||||
|
@ -112,10 +111,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];
|
||||
|
|
|
@ -147,7 +147,9 @@ export class ReportingCsvPanelAction implements ActionDefinition<ActionContext>
|
|||
const blob = new Blob([rawResponse as BlobPart], { type: 'text/csv;charset=utf-8;' });
|
||||
|
||||
// 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);
|
||||
|
|
|
@ -496,6 +496,7 @@ describe('Detections Rules API', () => {
|
|||
name: 'fileToImport',
|
||||
size: 89,
|
||||
type: 'json',
|
||||
webkitRelativePath: '/webkitRelativePath',
|
||||
arrayBuffer: jest.fn(),
|
||||
slice: jest.fn(),
|
||||
stream: jest.fn(),
|
||||
|
|
|
@ -371,6 +371,7 @@ const fetchAllPoliciesIfNeeded = async (
|
|||
|
||||
dispatch({
|
||||
type: 'policyDetailsListOfAllPoliciesStateChanged',
|
||||
// @ts-expect-error ts 4.5 upgrade
|
||||
payload: createLoadingResourceState(asStaleResourceState(currentPoliciesState)),
|
||||
});
|
||||
|
||||
|
|
|
@ -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
|
@ -5765,10 +5765,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" "*"
|
||||
|
@ -27757,10 +27757,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