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

refactor: Upgrade to TypeScript 5.5 #33187

Merged
merged 1 commit into from
Sep 2, 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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/meteor/client/hooks/useEndpointAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type UseEndpointActionOptions<TPathPattern extends PathPattern> = (undefined ext
export function useEndpointAction<TMethod extends Method, TPathPattern extends PathPattern>(
method: TMethod,
pathPattern: TPathPattern,
options: UseEndpointActionOptions<TPathPattern> = { keys: {} as UrlParams<TPathPattern> },
options: NoInfer<UseEndpointActionOptions<TPathPattern>> = { keys: {} as UrlParams<TPathPattern> },
) {
const sendData = useEndpoint(method, pathPattern, options.keys as UrlParams<TPathPattern>);

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/hooks/useEndpointData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ const deprecationWarning = log('useEndpointData is deprecated, use @tanstack/rea
*/
export const useEndpointData = <TPathPattern extends PathPattern>(
endpoint: TPathPattern,
options: {
options: NoInfer<{
keys?: UrlParams<TPathPattern>;
params?: OperationParams<'GET', TPathPattern>;
initialValue?: Serialized<OperationResult<'GET', TPathPattern>> | (() => Serialized<OperationResult<'GET', TPathPattern>>);
} = {},
}> = {},
): AsyncState<Serialized<OperationResult<'GET', TPathPattern>>> & {
reload: () => void;
} => {
Expand Down
14 changes: 7 additions & 7 deletions apps/meteor/client/lib/createRouteGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type IRouterPaths, type RouteName, type RouterPathPattern } from '@rocket.chat/ui-contexts';
import type { IRouterPaths, RouteName, RouterPathPattern } from '@rocket.chat/ui-contexts';
import React, { type ElementType, type ReactNode } from 'react';

import { router } from '../providers/RouterProvider';
Expand All @@ -9,21 +9,21 @@ type GroupName = 'omnichannel' | 'marketplace' | 'account' | 'admin';

type GroupPrefix<TGroupName extends GroupName> = IRouterPaths[`${TGroupName}-index`]['pattern'];

type RouteNamesOf<TGroupName extends GroupName> = Extract<
type RouteNamesOf<TGroupName extends GroupName> = (
| keyof {
[TRouteName in RouteName as IRouterPaths[TRouteName]['pattern'] extends `${GroupPrefix<TGroupName>}/${string}`
? TRouteName
: never]: never;
}
| `${GroupName}-index`,
RouteName
>;
| `${GroupName}-index`
) &
RouteName;

type TrimPrefix<T extends string, P extends string> = T extends `${P}${infer U}` ? U : T;
type TrimPrefix<T, P extends string> = T extends `${P}${infer U}` ? U : T;

export const createRouteGroup = <TGroupName extends GroupName>(
name: TGroupName,
prefix: GroupPrefix<TGroupName>,
prefix: NoInfer<GroupPrefix<TGroupName>>,
RouterComponent: ElementType<{
children?: ReactNode;
}>,
Expand Down
9 changes: 3 additions & 6 deletions apps/meteor/client/lib/getLocalePercentage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
export const getLocalePercentage = (locale: string, total: number, fraction: number, decimalCount = 2): string => {
const option = {
export const getLocalePercentage = (locale: string, total: number, fraction: number, decimalCount = 2) =>
new Intl.NumberFormat(locale, {
style: 'percent',
minimumFractionDigits: decimalCount,
maximumFractionDigits: decimalCount,
};

return new Intl.NumberFormat(locale, option).format(fraction / total);
};
}).format(fraction / total);
4 changes: 2 additions & 2 deletions apps/meteor/client/providers/CallProvider/CallProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@rocket.chat/core-typings';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { Random } from '@rocket.chat/random';
import type { Device, IExperimentalHTMLAudioElement } from '@rocket.chat/ui-contexts';
import type { Device } from '@rocket.chat/ui-contexts';
import {
useRouter,
useUser,
Expand Down Expand Up @@ -65,7 +65,7 @@ export const CallProvider = ({ children }: CallProviderProps) => {

const hasVoIPEnterpriseLicense = useIsVoipEnterprise();

const remoteAudioMediaRef = useRef<IExperimentalHTMLAudioElement>(null); // TODO: Create a dedicated file for the AUDIO and make the controls accessible
const remoteAudioMediaRef = useRef<HTMLAudioElement>(null); // TODO: Create a dedicated file for the AUDIO and make the controls accessible

const [queueCounter, setQueueCounter] = useState(0);
const [queueName, setQueueName] = useState('');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import type { Device, IExperimentalHTMLAudioElement, DeviceContextValue } from '@rocket.chat/ui-contexts';
import type { Device, DeviceContextValue } from '@rocket.chat/ui-contexts';
import { DeviceContext } from '@rocket.chat/ui-contexts';
import type { ReactElement, ReactNode } from 'react';
import React, { useEffect, useState, useMemo } from 'react';
Expand Down Expand Up @@ -33,7 +33,7 @@ export const DeviceProvider = ({ children }: DeviceProviderProps): ReactElement
};

const setAudioOutputDevice = useMutableCallback(
({ outputDevice, HTMLAudioElement }: { outputDevice: Device; HTMLAudioElement: IExperimentalHTMLAudioElement }): void => {
({ outputDevice, HTMLAudioElement }: { outputDevice: Device; HTMLAudioElement: HTMLAudioElement }): void => {
if (!isSetSinkIdAvailable()) {
throw new Error('setSinkId is not available in this browser');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { IExperimentalHTMLAudioElement } from '@rocket.chat/ui-contexts';

export const isSetSinkIdAvailable = (): boolean => {
const audio = new Audio() as IExperimentalHTMLAudioElement;
const audio = new Audio();
return !!audio.setSinkId;
};
2 changes: 1 addition & 1 deletion apps/meteor/client/providers/TranslationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const useI18next = (lng: string): typeof i18next => {
loadPath: 'i18n/{{lng}}.json',
parse: (data: string, _lngs?: string | string[], namespaces: string | string[] = []) =>
extractTranslationKeys(JSON.parse(data), namespaces),
request: (_options, url, _payload, callback) => {
request: (_options: unknown, url: string, _payload: unknown, callback: (error: unknown, data: unknown) => void) => {
const params = url.split('/');

const lng = params[params.length - 1];
Expand Down
15 changes: 8 additions & 7 deletions apps/meteor/client/views/admin/viewLogs/ansispan.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-control-regex */
const foregroundColors = {
30: 'var(--rcx-color-font-secondary-info, #6C727A)',
31: 'var(--rcx-color-font-danger, #D40C26)',
Expand All @@ -16,13 +17,13 @@ export const ansispan = (str: string): string => {
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;')
.replace(/(.\d{8}-\d\d:\d\d:\d\d\.\d\d\d\(?.{0,2}\)?)/, '<span>$1</span>')
.replace(/\033\[1m/g, '<strong>')
.replace(/\033\[22m/g, '</strong>')
.replace(/\033\[3m/g, '<em>')
.replace(/\033\[23m/g, '</em>')
.replace(/\033\[m/g, '</span>')
.replace(/\033\[0m/g, '</span>')
.replace(/\033\[39m/g, '</span>');
.replace(/\x1b\[1m/g, '<strong>')
.replace(/\x1b\[22m/g, '</strong>')
.replace(/\x1b\[3m/g, '<em>')
.replace(/\x1b\[23m/g, '</em>')
.replace(/\x1b\[m/g, '</span>')
.replace(/\x1b\[0m/g, '</span>')
.replace(/\x1b\[39m/g, '</span>');
return Object.entries(foregroundColors).reduce((str, [ansiCode, color]) => {
const span = `<span style="color: ${color}">`;
return str.replace(new RegExp(`\\033\\[${ansiCode}m`, 'g'), span).replace(new RegExp(`\\033\\[0;${ansiCode}m`, 'g'), span);
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"pino-pretty": "^7.6.1",
"pm2": "^5.2.0",
"ts-node": "^10.9.1",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"volta": {
"extends": "../../../package.json"
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"supports-color": "~7.2.0",
"template-file": "^6.0.1",
"ts-node": "^10.9.1",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"dependencies": {
"@babel/runtime": "~7.22.15",
Expand Down Expand Up @@ -430,7 +430,7 @@
"turndown": "^7.1.2",
"twilio": "^3.76.1",
"twit": "^2.2.11",
"typia": "^5.3.3",
"typia": "~6.9.0",
"ua-parser-js": "^1.0.37",
"underscore": "^1.13.6",
"universal-perf-hooks": "^1.0.1",
Expand Down
4 changes: 3 additions & 1 deletion apps/meteor/server/services/federation/Federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const allowedActionsInFederatedRooms: ValueOf<typeof RoomMemberActions>[] = [
RoomMemberActions.LEAVE,
];

const allowedActionsForModerators = allowedActionsInFederatedRooms.filter((action) => action !== RoomMemberActions.SET_AS_OWNER);
const allowedActionsForModerators: ValueOf<typeof RoomMemberActions>[] = allowedActionsInFederatedRooms.filter(
(action) => action !== RoomMemberActions.SET_AS_OWNER,
);

const allowedRoomSettingsChangesInFederatedRooms: ValueOf<typeof RoomSettingsEnum>[] = [RoomSettingsEnum.NAME, RoomSettingsEnum.TOPIC];

Expand Down
2 changes: 1 addition & 1 deletion ee/apps/account-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@types/polka": "^0.5.6",
"eslint": "~8.45.0",
"ts-node": "^10.9.1",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"main": "./dist/ee/apps/account-service/src/service.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion ee/apps/authorization-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@types/polka": "^0.5.6",
"eslint": "~8.45.0",
"ts-node": "^10.9.1",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"main": "./dist/ee/apps/authorization-service/src/service.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion ee/apps/ddp-streamer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"eslint": "~8.45.0",
"pino-pretty": "^7.6.1",
"ts-node": "^10.9.1",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"main": "./dist/service.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion ee/apps/omnichannel-transcript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@types/polka": "^0.5.6",
"eslint": "~8.45.0",
"ts-node": "^10.9.1",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"main": "./dist/ee/apps/omnichannel-transcript/src/service.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion ee/apps/presence-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@types/polka": "^0.5.6",
"eslint": "~8.45.0",
"ts-node": "^10.9.1",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"main": "./dist/ee/apps/presence-service/src/service.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion ee/apps/queue-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@types/polka": "^0.5.6",
"eslint": "~8.45.0",
"ts-node": "^10.9.1",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"main": "./dist/ee/apps/queue-worker/src/service.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion ee/apps/stream-hub-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@types/polka": "^0.5.6",
"eslint": "~8.45.0",
"ts-node": "^10.9.1",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"main": "./dist/ee/apps/stream-hub-service/src/service.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion ee/packages/license/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"eslint": "~8.45.0",
"jest": "~29.7.0",
"jest-websocket-mock": "~2.5.0",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"build": "tsc",
Expand Down
2 changes: 1 addition & 1 deletion ee/packages/omnichannel-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@types/jest": "~29.5.12",
"eslint": "~8.45.0",
"jest": "~29.7.0",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"dependencies": {
"@rocket.chat/core-services": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion ee/packages/pdf-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"eslint": "~8.45.0",
"jest": "~29.7.0",
"react-dom": "~18.3.1",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"build": "tsc -p tsconfig.build.json && cp -r src/public dist/public",
Expand Down
2 changes: 1 addition & 1 deletion ee/packages/presence/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"babel-jest": "^29.0.3",
"eslint": "~8.45.0",
"jest": "~29.7.0",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"lint": "eslint src",
Expand Down
2 changes: 1 addition & 1 deletion ee/packages/ui-theming/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"eslint-plugin-testing-library": "^5.11.1",
"react": "~17.0.2",
"react-docgen-typescript-plugin": "~1.0.5",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
"@storybook/react-docgen-typescript-plugin@1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0": "patch:@storybook/react-docgen-typescript-plugin@npm%3A1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0#./.yarn/patches/@storybook-react-docgen-typescript-plugin-npm-1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0-b31cc57c40.patch",
"mongodb@^4.17.1": "patch:mongodb@npm:4.17.1#.yarn/patches/mongodb-npm-4.17.1-a2fe811ff1.patch",
"@rocket.chat/forked-matrix-sdk-crypto-nodejs": "0.1.0-beta.13",
"[email protected]": "patch:typia@npm:5.3.3#.yarn/patches/typia-npm-5.3.3-21d3e18463.patch",
"typia@~5.3.3": "patch:typia@npm%3A5.3.3#./.yarn/patches/typia-npm-5.3.3-21d3e18463.patch"
"typia@~6.9.0": "patch:typia@npm%3A6.9.0#./.yarn/patches/typia-npm-6.9.0-2fd4d85f25.patch"
},
"dependencies": {
"node-gyp": "^9.4.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/account-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"devDependencies": {
"eslint": "~8.45.0",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
Expand Down
2 changes: 1 addition & 1 deletion packages/agenda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"devDependencies": {
"@types/debug": "^4.1.10",
"eslint": "~8.45.0",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"eslint": "~8.45.0",
"jest": "~29.7.0",
"jest-fetch-mock": "^3.0.3",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"build": "tsc",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"devDependencies": {
"eslint": "~8.45.0",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
Expand Down
2 changes: 1 addition & 1 deletion packages/base64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@typescript-eslint/parser": "~5.60.1",
"eslint": "~8.45.0",
"jest": "~29.7.0",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"volta": {
"extends": "../../package.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/cas-validate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"devDependencies": {
"eslint": "~8.45.0",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"jest": "~29.7.0",
"mongodb": "^4.17.2",
"prettier": "~2.8.8",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"eslint": "~8.45.0",
"mongodb": "^4.17.2",
"prettier": "~2.8.8",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
Expand Down
2 changes: 1 addition & 1 deletion packages/cron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"devDependencies": {
"eslint": "~8.45.0",
"typescript": "~5.3.3"
"typescript": "~5.5.4"
},
"scripts": {
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
Expand Down
2 changes: 1 addition & 1 deletion packages/ddp-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"eslint": "~8.45.0",
"jest": "~29.7.0",
"jest-websocket-mock": "~2.5.0",
"typescript": "~5.3.3",
"typescript": "~5.5.4",
"ws": "^8.13.0"
},
"peerDependencies": {
Expand Down
Loading
Loading