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 v5.1.6 #186437

Merged
merged 68 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
1fb5dd5
chore(NA): upgrade typescript into v5.1.6
mistic Jun 12, 2024
a1e9041
chore(NA): added expected errors annotations across the failing types
mistic Jun 14, 2024
87e8bf0
chore(NA): merge and solve conflicts with main
mistic Jun 19, 2024
8f31857
fix(NA): introduce other type checking fixes
mistic Jun 19, 2024
4a183b1
fix(NA): ts module resolution at packages/kbn-telemetry-tools/src/too…
mistic Jun 19, 2024
8f5443c
chore(NA): merge and solve conflicts with main
mistic Jun 19, 2024
f6a430e
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 19, 2024
8059de2
fix(NA): eslint at x-pack/plugins/security_solution/common/utils/fiel…
mistic Jun 19, 2024
a64df48
fix(NA): skip unit tests on ml schema_extractor for now
mistic Jun 19, 2024
7c38c54
fix(NA): storybook build with a resolution
mistic Jun 19, 2024
e98b09f
Merge branch 'upgrade-ts-v5.1' of github.com:mistic/kibana into upgra…
mistic Jun 19, 2024
50d4424
Merge branch 'main' into upgrade-ts-v5.1
mistic Jun 21, 2024
ae712a1
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 1, 2024
4f5a978
chore(NA): removing unused ts-expect-error directives
mistic Jul 2, 2024
1370455
Merge remote-tracking branch 'upstream/main' into upgrade-ts-v5.1
mistic Jul 2, 2024
ffa5fbc
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jul 2, 2024
62f8496
fix(NA): typechecks missing expect errors
mistic Jul 3, 2024
85096a0
chore(NA): merge and solve conflicts with main
mistic Jul 8, 2024
a79cb07
chore(NA): remove unused expect errors
mistic Jul 8, 2024
df302b5
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 9, 2024
26de051
chore(NA): remove unused expect errors
mistic Jul 9, 2024
9c8e80b
chore(NA): update tsd into latest version
mistic Jul 9, 2024
e9bfde5
chore(NA): update ts on buildkite side
mistic Jul 9, 2024
7acdfb9
chore(NA): deduplicate yarn lock
mistic Jul 9, 2024
d47a6ec
chore(NA): update lock file
mistic Jul 9, 2024
9588452
chore: fix vis codeowner type errors
nickofthyme Jul 9, 2024
1b883eb
fix security-entity-analytics errors
hop-dev Jul 10, 2024
cd20ae7
Fix ES|QL code type errors
stratoula Jul 10, 2024
9a84d72
fix some type errors
maximpn Jul 10, 2024
d648e7c
ML: fix ts errors
walterra Jul 10, 2024
154eb73
Handled the typescript changes for:
adcoelho Jul 10, 2024
7c76dd3
chore: remove unnecessary assert
nickofthyme Jul 10, 2024
3761ceb
TS fixes: adding Type where needed (#19)
kc13greiner Jul 10, 2024
931d5f5
chore(NA): merge and solve conflicts with main
mistic Jul 10, 2024
ca15fb0
chore(NA): remove non tracked file
mistic Jul 10, 2024
be66bde
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 11, 2024
ad09bb6
obs-ux-management: fix type error
maryam-saeidi Jul 11, 2024
4aa1fe5
ML: remove unnecessary binds
walterra Jul 11, 2024
36bd1ef
Upgrade ts v5.1 (#20)
kc13greiner Jul 12, 2024
56b004d
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 12, 2024
2fe3946
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 15, 2024
f846ecc
chore(NA): merge and solve conflicts with main
mistic Jul 15, 2024
a5678cd
fix(NA): eslint
mistic Jul 15, 2024
d3568ce
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 15, 2024
bf0422a
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 16, 2024
6c053fa
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 17, 2024
74ebee0
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 18, 2024
1458ac2
chore(NA): merge and solve conflicts with main
mistic Jul 19, 2024
d7be0e4
remove `.bind` since `asyncSearch` does not accept a parameter anymore
janmonschke Jul 22, 2024
754e86f
make sure we're comparing numbers
janmonschke Jul 22, 2024
fbabd38
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 22, 2024
4765ed8
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 22, 2024
85bb462
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 24, 2024
cca8248
Fix field formatter types
janmonschke Jul 24, 2024
7bb0243
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 24, 2024
e1c893f
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 24, 2024
117eab0
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jul 24, 2024
42f8f93
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 24, 2024
664b05a
remove unnecessary specified display: 'Off'
maximpn Jul 25, 2024
5a9a0df
specify missing fields
maximpn Jul 25, 2024
ffa4678
update a @ts-expect-error's comment
maximpn Jul 25, 2024
5a390a1
update runtime checks
maximpn Jul 25, 2024
4591c2a
remove a duplicated entry
maximpn Jul 25, 2024
e2369c9
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 29, 2024
fded4b1
test(NA): fix create_explorer_link.test.tsx
mistic Jul 29, 2024
3f969d8
chore(NA): missing expected type error
mistic Jul 29, 2024
56f0578
chore(NA): disable flay test
mistic Jul 29, 2024
9cbeab9
Merge branch 'main' into upgrade-ts-v5.1
mistic Jul 29, 2024
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
30 changes: 15 additions & 15 deletions .buildkite/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .buildkite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"chai": "^4.3.10",
"mocha": "^10.3.0",
"nock": "^12.0.2",
"ts-node": "^10.7.0",
"typescript": "^4.6.4"
"ts-node": "^10.9.2",
"typescript": "^5.1.6"
},
"imports": {
"#pipeline-utils": "./pipeline-utils/index.ts",
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
"**/react-intl/**/@types/react": "^17.0.45",
"**/remark-parse/trim": "1.0.1",
"**/sharp": "0.32.6",
"**/typescript": "4.9.5",
"**/typescript": "5.1.6",
"@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.cd77847.0",
"globby/fast-glob": "^3.2.11"
},
"dependencies": {
Expand Down Expand Up @@ -1424,7 +1425,6 @@
"@storybook/node-logger": "^6.5.16",
"@storybook/preview-web": "^6.5.16",
"@storybook/react": "^6.5.16",
"@storybook/react-docgen-typescript-plugin": "^1.0.1",
"@storybook/testing-react": "^1.3.0",
"@storybook/theming": "^6.5.16",
"@testing-library/jest-dom": "^5.16.5",
Expand Down Expand Up @@ -1742,8 +1742,8 @@
"tough-cookie": "^4.1.4",
"tree-kill": "^1.2.2",
"ts-morph": "^15.1.0",
"tsd": "^0.20.0",
"typescript": "4.9.5",
"tsd": "^0.31.1",
"typescript": "5.1.6",
"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 @@ -93,6 +93,7 @@ export class CoreVersionedRoute implements VersionedRoute {
{
path: this.path,
validate: passThroughValidation,
// @ts-expect-error upgrade typescript v5.1.6
options: this.getRouteConfigOptions(),
},
this.requestHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface State {

const convertToEui = (toast: ToastWithRichTitle): EuiToast => ({
...toast,
// @ts-expect-error upgrade typescript v5.1.6
title: toast.title instanceof Function ? <MountWrapper mount={toast.title} /> : toast.title,
text: toast.text instanceof Function ? <MountWrapper mount={toast.text} /> : toast.text,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type ComboBoxOption = EuiComboBoxOptionOption<RuleCreationValidConsumer>;

export const RuleConsumerSelection = (props: RuleConsumerSelectionProps) => {
const { validConsumers } = props;

const { multiConsumerSelection, baseErrors } = useRuleFormState();

const dispatch = useRuleFormDispatch();
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-es-query/src/es_query/from_filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const filterNegate = (reverse: boolean) => (filter: Filter) => {
* @return {Object} the query version of that filter
*/
const translateToQuery = (filter: Partial<Filter>): estypes.QueryDslQueryContainer => {
// @ts-expect-error upgrade typescript v5.1.6
return filter.query || filter;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const FormattedMessageShouldStartWithTheRightId: Rule.RuleModule = {
idAttribute.value.value;

const i18nAppId = getI18nIdentifierFromFilePath(filename, cwd);
// @ts-expect-error upgrade typescript v5.1.6
const functionDeclaration = sourceCode.getScope(node as TSNode)
.block as TSESTree.FunctionDeclaration;
const functionName = getFunctionName(functionDeclaration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const I18nTranslateShouldStartWithTheRightId: Rule.RuleModule = {
node.arguments[0].value;

const i18nAppId = getI18nIdentifierFromFilePath(filename, cwd);
// @ts-expect-error upgrade typescript v5.1.6
const functionDeclaration = sourceCode.getScope(node as TSNode)
.block as TSESTree.FunctionDeclaration;
const functionName = getFunctionName(functionDeclaration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const StringsShouldBeTranslatedWithFormattedMessage: Rule.RuleModule = {
if (intent === false) return;

const i18nAppId = getI18nIdentifierFromFilePath(filename, cwd);
// @ts-expect-error upgrade typescript v5.1.6
const functionDeclaration = sourceCode.getScope(node as TSNode)
.block as TSESTree.FunctionDeclaration;
const functionName = getFunctionName(functionDeclaration);
Expand Down Expand Up @@ -107,6 +108,7 @@ export const StringsShouldBeTranslatedWithFormattedMessage: Rule.RuleModule = {
if (intent === false) return;

const i18nAppId = getI18nIdentifierFromFilePath(filename, cwd);
// @ts-expect-error upgrade typescript v5.1.6
const functionDeclaration = sourceCode.getScope(node as TSNode)
.block as TSESTree.FunctionDeclaration;
const functionName = getFunctionName(functionDeclaration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const StringsShouldBeTranslatedWithI18n: Rule.RuleModule = {
if (intent === false) return;

const i18nAppId = getI18nIdentifierFromFilePath(filename, cwd);
// @ts-expect-error upgrade typescript v5.1.6
const functionDeclaration = sourceCode.getScope(node as TSNode)
.block as TSESTree.FunctionDeclaration;
const functionName = getFunctionName(functionDeclaration);
Expand Down Expand Up @@ -105,6 +106,7 @@ export const StringsShouldBeTranslatedWithI18n: Rule.RuleModule = {
if (intent === false) return;

const i18nAppId = getI18nIdentifierFromFilePath(filename, cwd);
// @ts-expect-error upgrade typescript v5.1.6
const functionDeclaration = sourceCode.getScope(node as TSNode)
.block as TSESTree.FunctionDeclaration;
const functionName = getFunctionName(functionDeclaration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const EventGeneratingElementsShouldBeInstrumented: Rule.RuleModule = {
}

const hasDataTestSubjProp = checkNodeForExistingDataTestSubjProp(parent, () =>
// @ts-expect-error upgrade typescript v5.1.6
sourceCode.getScope(node as TSNode)
);

Expand All @@ -69,6 +70,7 @@ export const EventGeneratingElementsShouldBeInstrumented: Rule.RuleModule = {
const appName = getAppName(fileName, cwd);

// 2. Component name
// @ts-expect-error upgrade typescript v5.1.6
const functionDeclaration = sourceCode.getScope(node as TSNode)
.block as TSESTree.FunctionDeclaration;
const functionName = getFunctionName(functionDeclaration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ const logDefinition: FunctionDefinition = {
// do not really care here about the base and field
// just need to check both values are not negative
for (const arg of fnDef.args) {
if (isLiteralItem(arg) && arg.value < 0) {
if (isLiteralItem(arg) && Number(arg.value) < 0) {
messages.push({
type: 'warning' as const,
code: 'logOfNegativeValue',
Expand Down Expand Up @@ -1446,7 +1446,7 @@ const log10Definition: FunctionDefinition = {
// do not really care here about the base and field
// just need to check both values are not negative
for (const arg of fnDef.args) {
if (isLiteralItem(arg) && arg.value < 0) {
if (isLiteralItem(arg) && Number(arg.value) < 0) {
messages.push({
type: 'warning' as const,
code: 'logOfNegativeValue',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const FieldDescription = <T extends SettingType>({
* Justification for dangerouslySetInnerHTML:
* Setting description may contain formatting and links to documentation.
*/
/* @ts-expect-error upgrade typescript v5.1.6 */
dangerouslySetInnerHTML={{ __html: content || '' }} // eslint-disable-line react/no-danger
/>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-repo-linter/lib/lint_target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ export abstract class LintTarget {
return this instanceof TsProjectLintTarget;
}

getTsProject() {
getTsProject(): any {
return this.isPackage() || this.isTsProject() ? this.tsProject : undefined;
}

getPkg() {
getPkg(): any {
return this.isPackage() ? this.pkg : undefined;
}
}
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": 152,
"kind": 154,
"type": "StringKeyword",
},
},
Expand Down
12 changes: 10 additions & 2 deletions packages/kbn-telemetry-tools/src/tools/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,16 @@ export function getResolvedModuleSourceFile(
originalSource: ts.SourceFile,
program: ts.Program,
importedModuleName: string
) {
const resolvedModule = (originalSource as any).resolvedModules.get(importedModuleName);
): ts.SourceFile {
// Resolve the module name to get the resolved module name result
const resolvedModuleNameResult = ts.resolveModuleName(
importedModuleName,
originalSource.fileName,
program.getCompilerOptions(),
ts.sys
);

const resolvedModule = resolvedModuleNameResult.resolvedModule;
if (!resolvedModule) {
throw new Error(
`Import for [${importedModuleName}] in [${originalSource.fileName}] could not be resolved by TypeScript`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,7 @@ export const UserProfilesSelectable = <Option extends UserProfileWithAvatar | nu
<EuiSelectable
data-test-subj={props['data-test-subj']}
options={displayedOptions}
// @ts-expect-error: Type of `nextOptions` in EuiSelectable does not match what's actually being passed back so need to manually override it
onChange={(
nextOptions: Array<EuiSelectableOption<{ data: Partial<UserProfileWithAvatar> }>>
) => {
onChange={(nextOptions: SelectableOption[]) => {
if (!onChange) {
return;
}
Expand Down Expand Up @@ -330,7 +327,7 @@ export const UserProfilesSelectable = <Option extends UserProfileWithAvatar | nu
noMatchesMessage={noMatchesMessage}
emptyMessage={emptyMessage}
errorMessage={errorMessage}
renderOption={(option, searchValue) => {
renderOption={(option: SelectableOption, searchValue) => {
if (option.user) {
const displayName = getUserDisplayName(option.user);
return (
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/bfetch/public/test_helpers/xhr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ export const mockXMLHttpRequest = (): {
XMLHttpRequest: typeof window.XMLHttpRequest;
} => {
class MockXMLHttpRequest implements XMLHttpRequest {
// @ts-expect-error upgrade typescript v5.1.6
DONE = 0;
// @ts-expect-error upgrade typescript v5.1.6
HEADERS_RECEIVED = 0;
// @ts-expect-error upgrade typescript v5.1.6
LOADING = 0;
// @ts-expect-error upgrade typescript v5.1.6
OPENED = 0;
// @ts-expect-error upgrade typescript v5.1.6
UNSENT = 0;
abort = jest.fn();
addEventListener = jest.fn();
Expand Down Expand Up @@ -52,6 +57,7 @@ export const mockXMLHttpRequest = (): {
const xhr = new MockXMLHttpRequest();

return {
// @ts-expect-error upgrade typescript v5.1.6
xhr,
XMLHttpRequest: class {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const config: PartitionChartProps['visConfig'] = {
export const pieConfig: PartitionVisParams = {
...config,
isDonut: false,
emptySizeRatio: 0,
emptySizeRatio: 0.3,
distinctColors: false,
nestedLegend: false,
dimensions: {
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/data/common/search/tabify/tabify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ describe('tabifyAggResponse Integration', () => {
) {
expect(typeof row).toBe('object');

asserts.forEach((assert, i: number) => {
asserts.forEach((a, i: number) => {
if (row[`col-${i}`]) {
assert(row[`col-${i}`]);
a(row[`col-${i}`]);
}
});
}
Expand All @@ -214,7 +214,7 @@ describe('tabifyAggResponse Integration', () => {
// check for something like an average bytes result
function expectAvgBytes(val: string | number) {
expect(typeof val).toBe('number');
expect(val === 0 || val > 1000).toBeDefined();
expect(val === 0 || +val > 1000).toBe(true);
}

test('for non-hierarchical vis', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const getExpirationStatus = (config: SearchSessionsConfigSchema, expires:
});
}

if (durationToExpire.valueOf() > 0 && expiresInDays <= sufficientDays) {
if (durationToExpire.asMilliseconds() > 0 && expiresInDays <= sufficientDays) {
return { toolTipContent, statusContent };
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export const sum: ExpressionFunctionDefinition<'sum', unknown[], {}, ExpressionV
fn: (values) => {
return {
type: 'num',
value: Array.isArray(values) ? values.reduce((a, b) => a + b) : values,
value: Array.isArray(values)
? values
.map(Number)
.filter(isFinite)
.reduce((a, b) => a + b, 0)
: values,
};
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const baseFormatters: FieldFormatInstanceType[] = [
StaticLookupFormat,
StringFormat,
TruncateFormat,
// @ts-expect-error upgrade typescript v5.1.6
UrlFormat,
HistogramFormat,
];
1 change: 1 addition & 0 deletions src/plugins/field_formats/common/converters/color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class ColorFormat extends FieldFormat {
return findLast(this.param('colors'), ({ range }) => {
if (!range) return;
const [start, end] = range.split(':');
// @ts-expect-error upgrade typescript v5.1.6
return val >= Number(start) && val <= Number(end);
});

Expand Down
1 change: 1 addition & 0 deletions src/plugins/field_formats/common/utils/geo_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { i18n } from '@kbn/i18n';
export const converter = new usng.Converter();

export function withinRange(value: string | number, min: number, max: number) {
// @ts-expect-error upgrade typescript v5.1.6
const isInvalid = value === '' || value > max || value < min;
const error = isInvalid
? i18n.translate('fieldFormats.geoUtils.outOfRangeErrorMsg', {
Expand Down
Loading