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

chore(NA): upgrade typescript into v4.7.4 #162738

Merged
merged 57 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
bd6b552
chore(NA): upgrade typescript into v4.7.4
mistic Jul 28, 2023
23ce0f5
fix(NA): include some type failures fixes
mistic Jul 28, 2023
1646204
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Jul 28, 2023
2476853
chore(NA): process more typescript errors
mistic Jul 28, 2023
350c645
Merge branch 'upgrade-typescript-v4-7-4' of github.com:mistic/kibana …
mistic Jul 28, 2023
07f9dd9
chore(NA): solve conflicts on security solution team tsconfig
mistic Jul 28, 2023
e51b25f
test(NA): fix jest snapshots for ts_program test
mistic Jul 29, 2023
764abb2
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Jul 29, 2023
14333fd
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Jul 30, 2023
ba114b5
Merge branch 'main' into upgrade-typescript-v4-7-4
kibanamachine Jul 31, 2023
8226553
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Jul 31, 2023
18d1a32
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jul 31, 2023
2c04675
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Jul 31, 2023
9b4e11c
chore(NA): fix type error on src/plugins/discover/public/components/d…
mistic Aug 1, 2023
7fe9755
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Aug 1, 2023
1ca2518
choer(NA): revert ops code on repo packages modern library
mistic Aug 1, 2023
d8f51b2
Merge branch 'upgrade-typescript-v4-7-4' of github.com:mistic/kibana …
mistic Aug 1, 2023
4651be3
choer(NA): revert ops code on repo packages modern library
mistic Aug 1, 2023
574b6a6
choer(NA): revert ops code on repo packages modern library
mistic Aug 1, 2023
5ce3095
chore(NA): get back function refactor
mistic Aug 1, 2023
e394c6c
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 2, 2023
0f1a075
Merge remote-tracking branch 'upstream/main' into upgrade-typescript-…
mistic Aug 2, 2023
b85e090
chore(NA): apply uptime type fixes and removed expect error
mistic Aug 2, 2023
4a13f60
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 2, 2023
e716dfe
fix(NA): types on test_serverless
mistic Aug 2, 2023
2de2a88
Merge branch 'upgrade-typescript-v4-7-4' of github.com:mistic/kibana …
mistic Aug 2, 2023
33f2fd0
fix(NA): replace any by KibanaRequest in x-pack/plugins/security/serv…
mistic Aug 3, 2023
42d295b
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 4, 2023
1afb54c
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 4, 2023
fa884df
chore(na): update packages/core/http/core-http-router-server-internal…
mistic Aug 4, 2023
ea5d7e5
chore(NA): update x-pack/plugins/security/server/session_management/s…
mistic Aug 4, 2023
8d34c31
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Aug 4, 2023
d398d24
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 7, 2023
a53bb8b
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 7, 2023
f33aa04
[Visualizations] fix types on TS upgrade (#16)
stratoula Aug 7, 2023
a746d2c
Improve Core types in preparation for ts v4.7.4 (#17)
rudolf Aug 7, 2023
1889900
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 7, 2023
f1f2f2d
fix(NA): tests on src/plugins/expressions/common/execution/execution.ts
mistic Aug 7, 2023
196b1d7
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 7, 2023
1752054
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 7, 2023
7455bfa
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 8, 2023
9e9cc12
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 9, 2023
0eb2ead
chore(NA): update x-pack/plugins/canvas/public/components/workpad_pag…
mistic Aug 9, 2023
887849a
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 9, 2023
a142f81
chore(NA): merge and solve conflicts with main
mistic Aug 10, 2023
6993cdc
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 10, 2023
7143196
chore(NA): merge and solve conflicts with main
mistic Aug 15, 2023
c22156e
Merge branch 'upgrade-typescript-v4-7-4' of github.com:mistic/kibana …
mistic Aug 15, 2023
e10faf0
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 16, 2023
89d8a9b
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 16, 2023
e5656de
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 16, 2023
e200ef2
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 16, 2023
5dbb957
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 18, 2023
673c440
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 21, 2023
08e6c51
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 21, 2023
babca50
Merge branch 'main' into upgrade-typescript-v4-7-4
mistic Aug 24, 2023
9727f61
fix(NA): new type errors
mistic Aug 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"**/hoist-non-react-statics": "^3.3.2",
"**/isomorphic-fetch/node-fetch": "^2.6.7",
"**/remark-parse/trim": "1.0.1",
"**/typescript": "4.6.3",
"**/typescript": "4.7.4",
"globby/fast-glob": "^3.2.11"
},
"dependencies": {
Expand Down Expand Up @@ -1542,7 +1542,7 @@
"tree-kill": "^1.2.2",
"ts-morph": "^13.0.2",
"tsd": "^0.20.0",
"typescript": "4.6.3",
"typescript": "4.7.4",
"url-loader": "^2.2.0",
"val-loader": "^1.1.1",
"vinyl-fs": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class CoreKibanaRequest<
public readonly rewrittenUrl?: URL;

/** @internal */
protected readonly [requestSymbol]: Request;
protected readonly [requestSymbol]!: Request;

constructor(
request: RawRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ type KibanaRequestWithQueryVersion = KibanaRequest<
{ [ELASTIC_HTTP_VERSION_QUERY_PARAM]: unknown }
>;

export function hasQueryVersion(request: KibanaRequest): request is KibanaRequestWithQueryVersion {
export function hasQueryVersion(
request: Mutable<KibanaRequest>
): request is Mutable<KibanaRequestWithQueryVersion> {
return isObject(request.query) && ELASTIC_HTTP_VERSION_QUERY_PARAM in request.query;
}
export function removeQueryVersion(request: Mutable<KibanaRequestWithQueryVersion>): void {
Expand Down
6 changes: 1 addition & 5 deletions packages/kbn-repo-packages/modern/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ function getPluginPackagesFilter(selector = {}) {
*/
function getDistributablePacakgesFilter() {
return (pkg) => {
if (
pkg.isDevOnly ||
pkg.manifest.type === 'functional-tests' ||
pkg.manifest.type === 'test-helper'
) {
if (pkg.isDevOnly()) {
jbudz marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('createKibanaProgram', () => {
"fetch": Object {
"typeDescriptor": Object {
"locale": Object {
"kind": 149,
"kind": 150,
"type": "StringKeyword",
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const LabelRotation = Object.freeze({
Horizontal: 0,
Vertical: 90,
Angled: 75,
VerticalRotation: 270,
});
export type LabelRotation = $Values<typeof LabelRotation>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ export const TableRow = ({
// We should improve this and show a helpful tooltip why the filter buttons are not
// there/disabled when there are ignored values.
const isFilterable = Boolean(
mapping(column)?.filterable && filter && !row.raw._ignored?.includes(column)
mapping(column)?.filterable &&
typeof filter === 'function' &&
!row.raw._ignored?.includes(column)
);
rowCells.push(
<TableCell
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/expressions/common/execution/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,18 +420,20 @@ export class Execution<
: of(resolvedArgs);

return args$.pipe(
tap((args) => this.execution.params.debug && Object.assign(head.debug, { args })),
tap((args) => this.execution.params.debug && Object.assign(head.debug ?? {}, { args })),
switchMap((args) => this.invokeFunction(fn, input, args)),
this.execution.params.partial ? identity : last(),
switchMap((output) => (getType(output) === 'error' ? throwError(output) : of(output))),
tap((output) => this.execution.params.debug && Object.assign(head.debug, { output })),
tap(
(output) => this.execution.params.debug && Object.assign(head.debug ?? {}, { output })
),
switchMap((output) => this.invokeChain<ChainOutput>(tail, output)),
catchError((rawError) => {
const error = createError(rawError);
error.error.message = `[${fnName}] > ${error.error.message}`;

if (this.execution.params.debug) {
Object.assign(head.debug, { error, rawError, success: false });
Object.assign(head.debug ?? {}, { error, rawError, success: false });
}

return of(error);
Expand All @@ -440,7 +442,7 @@ export class Execution<
}),
finalize(() => {
if (this.execution.params.debug) {
Object.assign(head.debug, { duration: now() - timeStart });
Object.assign(head.debug ?? {}, { duration: now() - timeStart });
}
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { KnownTypeToString } from '../types';
import { TypeString } from '../types';
import { ArgumentType } from './arguments';

export class ExpressionFunctionParameter<T = unknown> {
Expand Down Expand Up @@ -46,6 +46,6 @@ export class ExpressionFunctionParameter<T = unknown> {
}

accepts(type: string) {
return !this.types?.length || this.types.includes(type as KnownTypeToString<T>);
return !this.types?.length || this.types.includes(type as TypeString<T>);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';

import { SelectOption, SwitchOption } from '@kbn/vis-default-editor-plugin/public';
import { Labels } from '@kbn/charts-plugin/public';
import type { LabelRotation, Labels } from '@kbn/charts-plugin/public';

import { TruncateLabelsOption } from '../../common';
import { getRotateOptions } from '../../../collections';
Expand All @@ -34,7 +34,8 @@ function LabelOptions({
}: LabelOptionsProps) {
const setAxisLabelRotate = useCallback(
(paramName: 'rotate', value: Labels['rotate']) => {
setAxisLabel(paramName, Number(value));
const rotation = Number(value) as LabelRotation;
setAxisLabel(paramName, rotation);
},
[setAxisLabel]
);
Expand Down Expand Up @@ -96,6 +97,7 @@ function LabelOptions({
options={rotateOptions}
paramName="rotate"
value={axisLabels.rotate}
// @ts-ignore ts upgrade v4.7.4
setValue={setAxisLabelRotate}
/>
</EuiToolTip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ const setupHandler = (commit: CommitFn, canvasOrigin: CanvasOriginFn, zoomScale?

// only commits the cursor position if there's a way to latch onto x/y calculation (canvasOrigin is knowable)
// or if left button is being held down (i.e. an element is being dragged)
if (buttons === 1 || canvasOrigin) {
//
if (buttons === 1 || canvasOrigin !== undefined) {
commit('cursorPosition', { x, y, altKey, metaKey, shiftKey, ctrlKey });
} else {
// clears cursorPosition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe('CreateCaseForm', () => {
globalForm = form;

return (
// @ts-expect-error ts upgrade v4.7.4
<TestProviders {...testProviderProps}>
<Form form={form}>{children}</Form>
</TestProviders>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe('EditableMarkdown', () => {
});

return (
// @ts-expect-error ts upgrade v4.7.4
<TestProviders {...testProviderProps}>
<Form form={form}>{children}</Form>
</TestProviders>
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/common/experimental_features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const parseExperimentalConfigValue = (configValue: string[]): Experimenta
throw new FleetInvalidExperimentalValue(`[${value}] is not a supported experimental feature`);
}

// @ts-expect-error ts upgrade v4.7.4
enabledFeatures[value as keyof ExperimentalFeatures] = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('Agent policy advanced options content', () => {
// remove when feature flag is removed
ExperimentalFeaturesService.init({
...allowedExperimentalValues,
// @ts-expect-error ts upgrade v4.7.4
agentTamperProtectionEnabled: true,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('AgentPolicyListPage', () => {
// todo: this can be removed when agentTamperProtectionEnabled feature flag is enabled/deleted
ExperimentalFeaturesService.init({
...allowedExperimentalValues,
// @ts-expect-error ts upgrade v4.7.4
agentTamperProtectionEnabled: true,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ describe('agent_list_page', () => {
// todo: this can be removed when agentTamperProtectionEnabled feature flag is enabled/deleted
ExperimentalFeaturesService.init({
...allowedExperimentalValues,
// @ts-expect-error ts upgrade v4.7.4
agentTamperProtectionEnabled: true,
});

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/server/mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const createAppContextStartContractMock = (
securitySetup: securityMock.createSetup(),
securityStart: securityMock.createStart(),
logger: loggingSystemMock.create().get(),
// @ts-expect-error ts upgrade v4.7.4
experimentalFeatures: {
agentTamperProtectionEnabled: true,
diagnosticFileUploadEnabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class ExtensionPointStorageClient implements ExtensionPointStorageClientI
async pipeRun<
T extends ExtensionPoint['type'],
D extends NarrowExtensionPointToType<T> = NarrowExtensionPointToType<T>,
// @ts-expect-error ts upgrade v4.7.4
P extends Parameters<D['callback']> = Parameters<D['callback']>
>(
extensionType: T,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export interface ExtensionPointStorageClientInterface {
pipeRun<
T extends ExtensionPoint['type'],
D extends NarrowExtensionPointToType<T> = NarrowExtensionPointToType<T>,
// @ts-expect-error ts upgrade v4.7.4
P extends Parameters<D['callback']> = Parameters<D['callback']>
>(
extensionType: T,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export const ApmOverviewPage: React.FC<ComponentProps> = ({ clusters }) => {
getPageData={getPageData}
data-test-subj="apmOverviewPage"
>
{data && <ApmOverview {...data} onBrush={onBrush} zoomInfo={zoomInfo} />}
{
// @ts-expect-error ts upgrade v4.7.4
data && <ApmOverview {...data} onBrush={onBrush} zoomInfo={zoomInfo} />
}
</ApmTemplate>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ export const EntSearchOverviewPage: React.FC<ComponentProps> = ({ clusters }) =>
data-test-subj="entSearchOverviewPage"
>
<div data-test-subj="entSearchOverviewPage">
{data && <EnterpriseSearchOverview {...data} onBrush={onBrush} zoomInfo={zoomInfo} />}
{
// @ts-expect-error ts upgrade v4.7.4
data && <EnterpriseSearchOverview {...data} onBrush={onBrush} zoomInfo={zoomInfo} />
}
</div>
</EntSearchTemplate>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const fieldDescriptorToBrowserFieldMapper = (fields: FieldDescriptor[]):
const browserField = browserFieldFactory(field, category);

if (browserFields[category] && browserFields[category]) {
// @ts-expect-error ts upgrade to v4.7.4
Object.assign(browserFields[category].fields, browserField);
} else {
browserFields[category] = { fields: browserField };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class Authenticator {
...providerCommonOptions,
name,
logger: options.loggers.get(type, name),
urls: { loggedOut: (request) => this.getLoggedOutURL(request, type) },
urls: { loggedOut: (request: KibanaRequest) => this.getLoggedOutURL(request, type) },
}),
this.options.config.authc.providers[type]?.[name]
),
Expand All @@ -275,7 +275,8 @@ export class Authenticator {
name: '__http__',
logger: options.loggers.get(HTTPAuthenticationProvider.type),
urls: {
loggedOut: (request) => this.getLoggedOutURL(request, HTTPAuthenticationProvider.type),
loggedOut: (request: KibanaRequest) =>
this.getLoggedOutURL(request, HTTPAuthenticationProvider.type),
},
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,18 @@ export function getSessionIndexSettings({
},
},
mappings: {
dynamic: 'strict',
dynamic: 'strict' as const,
_meta: { [SESSION_INDEX_MAPPINGS_VERSION_META_FIELD_NAME]: SESSION_INDEX_MAPPINGS_VERSION },
properties: {
usernameHash: { type: 'keyword' },
provider: { properties: { name: { type: 'keyword' }, type: { type: 'keyword' } } },
idleTimeoutExpiration: { type: 'date' },
createdAt: { type: 'date' },
lifespanExpiration: { type: 'date' },
accessAgreementAcknowledged: { type: 'boolean' },
content: { type: 'binary' },
usernameHash: { type: 'keyword' as const },
provider: {
properties: { name: { type: 'keyword' as const }, type: { type: 'keyword' as const } },
},
idleTimeoutExpiration: { type: 'date' as const },
createdAt: { type: 'date' as const },
lifespanExpiration: { type: 'date' as const },
accessAgreementAcknowledged: { type: 'boolean' as const },
content: { type: 'binary' as const },
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,14 @@ export const createAppRootMockRenderer = (): AppContextTestRender => {
app: experimentalFeaturesReducer,
};

const store = createStore(mockGlobalState, storeReducer, kibanaObservable, storage, [
...managementMiddlewareFactory(coreStart, depsStart),
middlewareSpy.actionSpyMiddleware,
]);
const store = createStore(
mockGlobalState,
storeReducer,
kibanaObservable,
storage,
// @ts-expect-error ts upgrade v4.7.4
[...managementMiddlewareFactory(coreStart, depsStart), middlewareSpy.actionSpyMiddleware]
);

const queryClient = new QueryClient({
defaultOptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const OsqueryResponseAction = React.memo((props: OsqueryResponseActionPro
);
}

// @ts-expect-error ts upgrade v4.7.4
if (isMounted() && OsqueryForm) {
return (
<UseField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export const PageOverlay = memo<PageOverlayProps>(
useEffect(() => {
if (
isMounted() &&
// @ts-expect-error ts upgrade v4.7.4
onHide &&
hideOnUrlPathnameChange &&
!isHidden &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const EventCollectionCard = memo(

<div data-test-subj={getTestId('options')}>
{options.map(({ name, protectionField }) => {
const keyPath = `${policyOs}.events.${protectionField}`;
const keyPath = `${policyOs}.events.${String(protectionField)}`;

return (
<EventCheckbox
Expand Down Expand Up @@ -165,7 +165,7 @@ export const EventCollectionCard = memo(
indented,
isDisabled,
}) => {
const keyPath = `${policyOs}.events.${protectionField}`;
const keyPath = `${policyOs}.events.${String(protectionField)}`;
const isChecked = get(policy, keyPath);
const fieldString = protectionField as string;

Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/security_solution/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"server/**/*.json",
"scripts/**/*.json",
"public/**/*.json",
"../../../typings/**/*",
"./public/management/cypress/cypress.d.ts"
"../../../typings/**/*"
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const StorybookContextDecorator: React.FC<StorybookContextDecoratorProps>
ExperimentalFeaturesService.init({
experimentalFeatures: {
rulesListDatagrid: true,
// @ts-expect-error ts upgrade v4.7.4
internalAlertsTable: true,
ruleTagFilter: true,
ruleStatusFilter: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const parseExperimentalConfigValue = (configValue: string[]): Experimenta
throw new TriggersActionsUIInvalidExperimentalValue(`[${value}] is not valid.`);
}

// @ts-expect-error ts upgrade v4.7.4
enabledFeatures[value as keyof ExperimentalFeatures] = true;
}

Expand Down
Loading