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

[8.15] chore(NA): upgrade typescript into v5.1.6 #191794

Merged
merged 6 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -94,7 +94,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 @@ -1429,7 +1430,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 @@ -1748,8 +1748,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 @@ -45,6 +45,7 @@ export const RuleAlertDelay = (props: RuleAlertDelayProps) => {
return (
<EuiFormRow
fullWidth
// @ts-expect-error upgrade typescript v5.1.6
isInvalid={errors.alertDelay?.length > 0}
error={errors.alertDelay}
data-test-subj="alertDelay"
Expand All @@ -57,6 +58,7 @@ export const RuleAlertDelay = (props: RuleAlertDelayProps) => {
name="alertDelay"
data-test-subj="alertDelayInput"
prepend={[ALERT_DELAY_TITLE_PREFIX]}
// @ts-expect-error upgrade typescript v5.1.6
isInvalid={errors.alertDelay?.length > 0}
append={ALERT_DELAY_TITLE_SUFFIX}
onChange={onAlertDelayChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type ComboBoxOption = EuiComboBoxOptionOption<RuleCreationValidConsumer>;
export const RuleConsumerSelection = (props: RuleConsumerSelectionProps) => {
const { consumers, selectedConsumer, errors = {}, onChange } = props;

// @ts-expect-error upgrade typescript v5.1.6
const isInvalid = (errors.consumer?.length || 0) > 0;

const validatedSelectedConsumer = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface RuleScheduleProps {
export const RuleSchedule = (props: RuleScheduleProps) => {
const { interval, minimumScheduleInterval, errors = {}, onChange } = props;

// @ts-expect-error upgrade typescript v5.1.6
const hasIntervalError = errors.interval?.length > 0;

const intervalNumber = getDurationNumberInItsUnit(interval);
Expand Down Expand Up @@ -99,6 +100,7 @@ export const RuleSchedule = (props: RuleScheduleProps) => {
data-test-subj="ruleSchedule"
display="rowCompressed"
helpText={helpText}
// @ts-expect-error upgrade typescript v5.1.6
isInvalid={errors.interval?.length > 0}
error={errors.interval}
>
Expand All @@ -107,6 +109,7 @@ export const RuleSchedule = (props: RuleScheduleProps) => {
<EuiFieldNumber
fullWidth
prepend={[SCHEDULE_TITLE_PREFIX]}
// @ts-expect-error upgrade typescript v5.1.6
isInvalid={errors.interval?.length > 0}
value={intervalNumber}
name="interval"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const RuleDetails = (props: RuleDetailsProps) => {
<EuiFormRow
fullWidth
label={RULE_NAME_INPUT_TITLE}
// @ts-expect-error upgrade typescript v5.1.6
isInvalid={errors.name?.length > 0}
error={errors.name}
>
Expand All @@ -98,6 +99,7 @@ export const RuleDetails = (props: RuleDetailsProps) => {
<EuiFormRow
fullWidth
label={RULE_TAG_INPUT_TITLE}
// @ts-expect-error upgrade typescript v5.1.6
isInvalid={errors.tags?.length > 0}
error={errors.tags}
>
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 @@ -1361,7 +1361,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 @@ -1414,7 +1414,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
Loading
Loading