Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Comply with noImplicitAny #9940

Merged
merged 10 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,13 @@
"@types/flux": "^3.1.9",
"@types/fs-extra": "^9.0.13",
"@types/geojson": "^7946.0.8",
"@types/glob-to-regexp": "^0.4.1",
"@types/jest": "^29.2.1",
"@types/katex": "^0.14.0",
"@types/lodash": "^4.14.168",
"@types/modernizr": "^3.5.3",
"@types/node": "^16",
"@types/node-fetch": "^2.6.2",
"@types/pako": "^2.0.0",
"@types/parse5": "^6.0.0",
"@types/qrcode": "^1.3.5",
Expand All @@ -168,6 +170,7 @@
"@types/react-test-renderer": "^17.0.1",
"@types/react-transition-group": "^4.4.0",
"@types/sanitize-html": "^2.3.1",
"@types/tar-js": "^0.3.2",
"@types/ua-parser-js": "^0.7.36",
"@types/zxcvbn": "^4.4.0",
"@typescript-eslint/eslint-plugin": "^5.35.1",
Expand Down
2 changes: 1 addition & 1 deletion src/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ declare global {
processorCtor: (new (options?: AudioWorkletNodeOptions) => AudioWorkletProcessor) & {
parameterDescriptors?: AudioParamDescriptor[];
},
);
): void;

// eslint-disable-next-line no-var
var grecaptcha:
Expand Down
65 changes: 65 additions & 0 deletions src/@types/opus-recorder.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
Copyright 2023 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

declare module "opus-recorder/dist/recorder.min.js" {
export default class Recorder {
public static isRecordingSupported(): boolean;

public constructor(config: {
bufferLength?: number;
encoderApplication?: number;
encoderFrameSize?: number;
encoderPath?: string;
encoderSampleRate?: number;
encoderBitRate?: number;
maxFramesPerPage?: number;
mediaTrackConstraints?: boolean;
monitorGain?: number;
numberOfChannels?: number;
recordingGain?: number;
resampleQuality?: number;
streamPages?: boolean;
wavBitDepth?: number;
sourceNode?: MediaStreamAudioSourceNode;
encoderComplexity?: number;
});

public ondataavailable?(data: ArrayBuffer): void;

public readonly encodedSamplePosition: number;

public start(): Promise<void>;

public stop(): Promise<void>;

public close(): void;
}
}

declare module "opus-recorder/dist/encoderWorker.min.js" {
const path: string;
export default path;
}

declare module "opus-recorder/dist/waveWorker.min.js" {
const path: string;
export default path;
}

declare module "opus-recorder/dist/decoderWorker.min.js" {
const path: string;
export default path;
}
31 changes: 20 additions & 11 deletions src/AddThreepid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { IRequestMsisdnTokenResponse, IRequestTokenResponse } from "matrix-js-sdk/src/matrix";
import { IAuthData, IRequestMsisdnTokenResponse, IRequestTokenResponse } from "matrix-js-sdk/src/matrix";

import { MatrixClientPeg } from "./MatrixClientPeg";
import Modal from "./Modal";
Expand All @@ -29,6 +29,12 @@ function getIdServerDomain(): string {
return MatrixClientPeg.get().idBaseUrl.split("://")[1];
}

export type Binding = {
bind: boolean;
label: string;
errorTitle: string;
};

/**
* Allows a user to add a third party identifier to their homeserver and,
* optionally, the identity servers.
Expand Down Expand Up @@ -178,7 +184,7 @@ export default class AddThreepid {
* with a "message" property which contains a human-readable message detailing why
* the request failed.
*/
public async checkEmailLinkClicked(): Promise<any[]> {
public async checkEmailLinkClicked(): Promise<[boolean, IAuthData | Error | null]> {
try {
if (await MatrixClientPeg.get().doesServerSupportSeparateAddAndBind()) {
if (this.bind) {
Expand Down Expand Up @@ -220,16 +226,19 @@ export default class AddThreepid {
continueKind: "primary",
},
};
const { finished } = Modal.createDialog(InteractiveAuthDialog, {
title: _t("Add Email Address"),
matrixClient: MatrixClientPeg.get(),
authData: e.data,
makeRequest: this.makeAddThreepidOnlyRequest,
aestheticsForStagePhases: {
[SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics,
[SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: dialogAesthetics,
const { finished } = Modal.createDialog<[boolean, IAuthData | Error | null]>(
InteractiveAuthDialog,
{
title: _t("Add Email Address"),
matrixClient: MatrixClientPeg.get(),
authData: e.data,
makeRequest: this.makeAddThreepidOnlyRequest,
aestheticsForStagePhases: {
[SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics,
[SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: dialogAesthetics,
},
},
});
);
return finished;
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/AsyncWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ interface IState {
export default class AsyncWrapper extends React.Component<IProps, IState> {
private unmounted = false;

public state = {
component: null,
error: null,
};
public state: IState = {};

public componentDidMount(): void {
// XXX: temporary logging to try to diagnose
Expand Down
2 changes: 1 addition & 1 deletion src/BasePlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default abstract class BasePlatform {
room: Room,
ev?: MatrixEvent,
): Notification {
const notifBody = {
const notifBody: NotificationOptions = {
body: msg,
silent: true, // we play our own sounds
};
Expand Down
2 changes: 1 addition & 1 deletion src/HtmlUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const transformTags: IExtendedSanitizeOptions["transformTags"] = {

// Sanitise and transform data-mx-color and data-mx-bg-color to their CSS
// equivalents
const customCSSMapper = {
const customCSSMapper: Record<string, string> = {
"data-mx-color": "color",
"data-mx-bg-color": "background-color",
// $customAttributeKey: $cssAttributeKey
Expand Down
8 changes: 8 additions & 0 deletions src/IConfigOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,18 @@ export interface IConfigOptions {
inline?: {
left?: string;
right?: string;
pattern?: {
tex?: string;
latex?: string;
};
};
display?: {
left?: string;
right?: string;
pattern?: {
tex?: string;
latex?: string;
};
};
};

Expand Down
4 changes: 3 additions & 1 deletion src/Keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from "react";

export const Key = {
HOME: "Home",
END: "End",
Expand Down Expand Up @@ -76,7 +78,7 @@ export const Key = {

export const IS_MAC = navigator.platform.toUpperCase().includes("MAC");

export function isOnlyCtrlOrCmdKeyEvent(ev: KeyboardEvent): boolean {
export function isOnlyCtrlOrCmdKeyEvent(ev: React.KeyboardEvent | KeyboardEvent): boolean {
if (IS_MAC) {
return ev.metaKey && !ev.altKey && !ev.ctrlKey && !ev.shiftKey;
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/LegacyCallHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ export default class LegacyCallHandler extends EventEmitter {
private transferees = new Map<string, MatrixCall>(); // callId (target) -> call (transferee)
private audioPromises = new Map<AudioID, Promise<void>>();
private audioElementsWithListeners = new Map<HTMLMediaElement, boolean>();
private supportsPstnProtocol = null;
private pstnSupportPrefixed = null; // True if the server only support the prefixed pstn protocol
private supportsSipNativeVirtual = null; // im.vector.protocol.sip_virtual and im.vector.protocol.sip_native
private supportsPstnProtocol: boolean | null = null;
private pstnSupportPrefixed: boolean | null = null; // True if the server only support the prefixed pstn protocol
private supportsSipNativeVirtual: boolean | null = null; // im.vector.protocol.sip_virtual and im.vector.protocol.sip_native

// Map of the asserted identity users after we've looked them up using the API.
// We need to be be able to determine the mapped room synchronously, so we
Expand All @@ -187,7 +187,7 @@ export default class LegacyCallHandler extends EventEmitter {
// check asserted identity: if we're not obeying asserted identity,
// this map will never be populated, but we check anyway for sanity
if (this.shouldObeyAssertedfIdentity()) {
const nativeUser = this.assertedIdentityNativeUsers[call.callId];
const nativeUser = this.assertedIdentityNativeUsers.get(call.callId);
if (nativeUser) {
const room = findDMForUser(MatrixClientPeg.get(), nativeUser);
if (room) return room.roomId;
Expand Down Expand Up @@ -466,8 +466,8 @@ export default class LegacyCallHandler extends EventEmitter {
return this.getAllActiveCallsNotInRoom(roomId);
}

public getTransfereeForCallId(callId: string): MatrixCall {
return this.transferees[callId];
public getTransfereeForCallId(callId: string): MatrixCall | undefined {
return this.transferees.get(callId);
}

public play(audioId: AudioID): void {
Expand Down Expand Up @@ -621,7 +621,7 @@ export default class LegacyCallHandler extends EventEmitter {
logger.log(`Asserted identity ${newAssertedIdentity} mapped to ${newNativeAssertedIdentity}`);

if (newNativeAssertedIdentity) {
this.assertedIdentityNativeUsers[call.callId] = newNativeAssertedIdentity;
this.assertedIdentityNativeUsers.set(call.callId, newNativeAssertedIdentity);

// If we don't already have a room with this user, make one. This will be slightly odd
// if they called us because we'll be inviting them, but there's not much we can do about
Expand Down Expand Up @@ -917,7 +917,7 @@ export default class LegacyCallHandler extends EventEmitter {
return;
}
if (transferee) {
this.transferees[call.callId] = transferee;
this.transferees.set(call.callId, transferee);
}

this.setCallListeners(call);
Expand Down
8 changes: 4 additions & 4 deletions src/Login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ export default class Login {
}

public loginViaPassword(
username: string,
phoneCountry: string,
phoneNumber: string,
username: string | undefined,
phoneCountry: string | undefined,
phoneNumber: string | undefined,
password: string,
): Promise<IMatrixClientCreds> {
const isEmail = username.indexOf("@") > 0;
const isEmail = username?.indexOf("@") > 0;

let identifier;
if (phoneCountry && phoneNumber) {
Expand Down
4 changes: 2 additions & 2 deletions src/MediaDeviceHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export enum MediaDeviceHandlerEvent {
}

export default class MediaDeviceHandler extends EventEmitter {
private static internalInstance;
private static internalInstance?: MediaDeviceHandler;

public static get instance(): MediaDeviceHandler {
if (!MediaDeviceHandler.internalInstance) {
Expand Down Expand Up @@ -67,7 +67,7 @@ export default class MediaDeviceHandler extends EventEmitter {
public static async getDevices(): Promise<IMediaDevices> {
try {
const devices = await navigator.mediaDevices.enumerateDevices();
const output = {
const output: Record<MediaDeviceKindEnum, MediaDeviceInfo[]> = {
[MediaDeviceKindEnum.AudioOutput]: [],
[MediaDeviceKindEnum.AudioInput]: [],
[MediaDeviceKindEnum.VideoInput]: [],
Expand Down
6 changes: 3 additions & 3 deletions src/NodeAnimator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from "react";
import React, { ReactInstance } from "react";
import ReactDom from "react-dom";

interface IChildProps {
Expand All @@ -41,7 +41,7 @@ interface IProps {
* automatic positional animation, look at react-shuffle or similar libraries.
*/
export default class NodeAnimator extends React.Component<IProps> {
private nodes = {};
private nodes: Record<string, ReactInstance> = {};
private children: { [key: string]: React.DetailedReactHTMLElement<any, HTMLElement> };
public static defaultProps: Partial<IProps> = {
startStyles: [],
Expand All @@ -65,7 +65,7 @@ export default class NodeAnimator extends React.Component<IProps> {
*/
private applyStyles(node: HTMLElement, styles: React.CSSProperties): void {
Object.entries(styles).forEach(([property, value]) => {
node.style[property] = value;
node.style[property as keyof Omit<CSSStyleDeclaration, "length" | "parentRule">] = value;
});
}

Expand Down
Loading