Comply with noImplicitAny (#9940)
* Stash noImplicitAny work * Stash * Fix imports * Iterate * Fix tests * Delint * Fix tests
This commit is contained in:
parent
ac7f69216e
commit
61a63e47f4
359 changed files with 1621 additions and 1353 deletions
|
@ -33,6 +33,7 @@ import QuestionDialog from "../dialogs/QuestionDialog";
|
|||
const FIELD_OLD_PASSWORD = "field_old_password";
|
||||
const FIELD_NEW_PASSWORD = "field_new_password";
|
||||
const FIELD_NEW_PASSWORD_CONFIRM = "field_new_password_confirm";
|
||||
type FieldType = typeof FIELD_OLD_PASSWORD | typeof FIELD_NEW_PASSWORD | typeof FIELD_NEW_PASSWORD_CONFIRM;
|
||||
|
||||
enum Phase {
|
||||
Edit = "edit",
|
||||
|
@ -59,7 +60,7 @@ interface IProps {
|
|||
}
|
||||
|
||||
interface IState {
|
||||
fieldValid: {};
|
||||
fieldValid: Partial<Record<FieldType, boolean>>;
|
||||
phase: Phase;
|
||||
oldPassword: string;
|
||||
newPassword: string;
|
||||
|
@ -67,6 +68,10 @@ interface IState {
|
|||
}
|
||||
|
||||
export default class ChangePassword extends React.Component<IProps, IState> {
|
||||
private [FIELD_OLD_PASSWORD]: Field;
|
||||
private [FIELD_NEW_PASSWORD]: Field;
|
||||
private [FIELD_NEW_PASSWORD_CONFIRM]: Field;
|
||||
|
||||
public static defaultProps: Partial<IProps> = {
|
||||
onFinished() {},
|
||||
onError() {},
|
||||
|
@ -221,7 +226,7 @@ export default class ChangePassword extends React.Component<IProps, IState> {
|
|||
);
|
||||
};
|
||||
|
||||
private markFieldValid(fieldID: string, valid: boolean): void {
|
||||
private markFieldValid(fieldID: FieldType, valid: boolean): void {
|
||||
const { fieldValid } = this.state;
|
||||
fieldValid[fieldID] = valid;
|
||||
this.setState({
|
||||
|
@ -317,7 +322,11 @@ export default class ChangePassword extends React.Component<IProps, IState> {
|
|||
activeElement.blur();
|
||||
}
|
||||
|
||||
const fieldIDsInDisplayOrder = [FIELD_OLD_PASSWORD, FIELD_NEW_PASSWORD, FIELD_NEW_PASSWORD_CONFIRM];
|
||||
const fieldIDsInDisplayOrder: FieldType[] = [
|
||||
FIELD_OLD_PASSWORD,
|
||||
FIELD_NEW_PASSWORD,
|
||||
FIELD_NEW_PASSWORD_CONFIRM,
|
||||
];
|
||||
|
||||
// Run all fields with stricter validation that no longer allows empty
|
||||
// values for required fields.
|
||||
|
@ -358,7 +367,7 @@ export default class ChangePassword extends React.Component<IProps, IState> {
|
|||
return Object.values(this.state.fieldValid).every(Boolean);
|
||||
}
|
||||
|
||||
private findFirstInvalidField(fieldIDs: string[]): Field {
|
||||
private findFirstInvalidField(fieldIDs: FieldType[]): Field {
|
||||
for (const fieldID of fieldIDs) {
|
||||
if (!this.state.fieldValid[fieldID] && this[fieldID]) {
|
||||
return this[fieldID];
|
||||
|
|
|
@ -43,7 +43,7 @@ interface IState {
|
|||
export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
|
||||
private unmounted = false;
|
||||
|
||||
public constructor(props) {
|
||||
public constructor(props: {}) {
|
||||
super(props);
|
||||
|
||||
this.state = {};
|
||||
|
|
|
@ -114,7 +114,7 @@ export default class CryptographyPanel extends React.Component<IProps, IState> {
|
|||
);
|
||||
};
|
||||
|
||||
private updateBlacklistDevicesFlag = (checked): void => {
|
||||
private updateBlacklistDevicesFlag = (checked: boolean): void => {
|
||||
MatrixClientPeg.get().setGlobalBlacklistUnverifiedDevices(checked);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ interface IState {
|
|||
}
|
||||
|
||||
export default class EventIndexPanel extends React.Component<{}, IState> {
|
||||
public constructor(props) {
|
||||
public constructor(props: {}) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
|
|
|
@ -214,7 +214,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
|
|||
|
||||
private async refreshRules(): Promise<Partial<IState>> {
|
||||
const ruleSets = await MatrixClientPeg.get().getPushRules();
|
||||
const categories = {
|
||||
const categories: Record<string, RuleClass> = {
|
||||
[RuleId.Master]: RuleClass.Master,
|
||||
|
||||
[RuleId.DM]: RuleClass.VectorGlobal,
|
||||
|
|
|
@ -83,7 +83,7 @@ interface IState {
|
|||
export default class SetIdServer extends React.Component<IProps, IState> {
|
||||
private dispatcherRef: string;
|
||||
|
||||
public constructor(props) {
|
||||
public constructor(props: IProps) {
|
||||
super(props);
|
||||
|
||||
let defaultIdServer = "";
|
||||
|
@ -288,8 +288,8 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
let message;
|
||||
let danger = false;
|
||||
const messageElements = {
|
||||
idserver: (sub) => <b>{abbreviateUrl(currentClientIdServer)}</b>,
|
||||
b: (sub) => <b>{sub}</b>,
|
||||
idserver: (sub: string) => <b>{abbreviateUrl(currentClientIdServer)}</b>,
|
||||
b: (sub: string) => <b>{sub}</b>,
|
||||
};
|
||||
if (!currentServerReachable) {
|
||||
message = (
|
||||
|
|
|
@ -17,17 +17,17 @@ limitations under the License.
|
|||
import React from "react";
|
||||
|
||||
import SpellCheckLanguagesDropdown from "../../../components/views/elements/SpellCheckLanguagesDropdown";
|
||||
import AccessibleButton from "../../../components/views/elements/AccessibleButton";
|
||||
import AccessibleButton, { ButtonEvent } from "../../../components/views/elements/AccessibleButton";
|
||||
import { _t } from "../../../languageHandler";
|
||||
|
||||
interface ExistingSpellCheckLanguageIProps {
|
||||
language: string;
|
||||
onRemoved(language: string);
|
||||
onRemoved(language: string): void;
|
||||
}
|
||||
|
||||
interface SpellCheckLanguagesIProps {
|
||||
languages: Array<string>;
|
||||
onLanguagesChange(languages: Array<string>);
|
||||
onLanguagesChange(languages: Array<string>): void;
|
||||
}
|
||||
|
||||
interface SpellCheckLanguagesIState {
|
||||
|
@ -35,7 +35,7 @@ interface SpellCheckLanguagesIState {
|
|||
}
|
||||
|
||||
export class ExistingSpellCheckLanguage extends React.Component<ExistingSpellCheckLanguageIProps> {
|
||||
private onRemove = (e): void => {
|
||||
private onRemove = (e: ButtonEvent): void => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
|
@ -55,7 +55,7 @@ export class ExistingSpellCheckLanguage extends React.Component<ExistingSpellChe
|
|||
}
|
||||
|
||||
export default class SpellCheckLanguages extends React.Component<SpellCheckLanguagesIProps, SpellCheckLanguagesIState> {
|
||||
public constructor(props) {
|
||||
public constructor(props: SpellCheckLanguagesIProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
newLanguage: "",
|
||||
|
@ -67,7 +67,7 @@ export default class SpellCheckLanguages extends React.Component<SpellCheckLangu
|
|||
this.props.onLanguagesChange(languages);
|
||||
};
|
||||
|
||||
private onAddClick = (e): void => {
|
||||
private onAddClick = (e: ButtonEvent): void => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ interface IProps {
|
|||
|
||||
interface IState {
|
||||
verifying: boolean;
|
||||
addTask: any; // FIXME: When AddThreepid is TSfied
|
||||
addTask: AddThreepid;
|
||||
continueDisabled: boolean;
|
||||
newEmailAddress: string;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ export default class EmailAddresses extends React.Component<IProps, IState> {
|
|||
};
|
||||
}
|
||||
|
||||
private onRemoved = (address): void => {
|
||||
private onRemoved = (address: IThreepid): void => {
|
||||
const emails = this.props.emails.filter((e) => e !== address);
|
||||
this.props.onEmailsChange(emails);
|
||||
};
|
||||
|
|
|
@ -131,7 +131,7 @@ interface IState {
|
|||
verifying: boolean;
|
||||
verifyError: string;
|
||||
verifyMsisdn: string;
|
||||
addTask: any; // FIXME: When AddThreepid is TSfied
|
||||
addTask: AddThreepid;
|
||||
continueDisabled: boolean;
|
||||
phoneCountry: string;
|
||||
newPhoneNumber: string;
|
||||
|
|
|
@ -22,7 +22,7 @@ import { logger } from "matrix-js-sdk/src/logger";
|
|||
import { _t } from "../../../../languageHandler";
|
||||
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
||||
import Modal from "../../../../Modal";
|
||||
import AddThreepid from "../../../../AddThreepid";
|
||||
import AddThreepid, { Binding } from "../../../../AddThreepid";
|
||||
import ErrorDialog from "../../dialogs/ErrorDialog";
|
||||
import AccessibleButton from "../../elements/AccessibleButton";
|
||||
|
||||
|
@ -74,7 +74,7 @@ export class EmailAddress extends React.Component<IEmailAddressProps, IEmailAddr
|
|||
}
|
||||
}
|
||||
|
||||
private async changeBinding({ bind, label, errorTitle }): Promise<void> {
|
||||
private async changeBinding({ bind, label, errorTitle }: Binding): Promise<void> {
|
||||
if (!(await MatrixClientPeg.get().doesServerSupportSeparateAddAndBind())) {
|
||||
return this.changeBindingTangledAddBind({ bind, label, errorTitle });
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ export class EmailAddress extends React.Component<IEmailAddressProps, IEmailAddr
|
|||
}
|
||||
}
|
||||
|
||||
private async changeBindingTangledAddBind({ bind, label, errorTitle }): Promise<void> {
|
||||
private async changeBindingTangledAddBind({ bind, label, errorTitle }: Binding): Promise<void> {
|
||||
const { medium, address } = this.props.email;
|
||||
|
||||
const task = new AddThreepid();
|
||||
|
|
|
@ -22,7 +22,7 @@ import { logger } from "matrix-js-sdk/src/logger";
|
|||
import { _t } from "../../../../languageHandler";
|
||||
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
||||
import Modal from "../../../../Modal";
|
||||
import AddThreepid from "../../../../AddThreepid";
|
||||
import AddThreepid, { Binding } from "../../../../AddThreepid";
|
||||
import ErrorDialog from "../../dialogs/ErrorDialog";
|
||||
import Field from "../../elements/Field";
|
||||
import AccessibleButton from "../../elements/AccessibleButton";
|
||||
|
@ -70,7 +70,7 @@ export class PhoneNumber extends React.Component<IPhoneNumberProps, IPhoneNumber
|
|||
}
|
||||
}
|
||||
|
||||
private async changeBinding({ bind, label, errorTitle }): Promise<void> {
|
||||
private async changeBinding({ bind, label, errorTitle }: Binding): Promise<void> {
|
||||
if (!(await MatrixClientPeg.get().doesServerSupportSeparateAddAndBind())) {
|
||||
return this.changeBindingTangledAddBind({ bind, label, errorTitle });
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ export class PhoneNumber extends React.Component<IPhoneNumberProps, IPhoneNumber
|
|||
}
|
||||
}
|
||||
|
||||
private async changeBindingTangledAddBind({ bind, label, errorTitle }): Promise<void> {
|
||||
private async changeBindingTangledAddBind({ bind, label, errorTitle }: Binding): Promise<void> {
|
||||
const { medium, address } = this.props.msisdn;
|
||||
|
||||
const task = new AddThreepid();
|
||||
|
|
|
@ -47,8 +47,8 @@ interface IState {
|
|||
}
|
||||
|
||||
export default class AdvancedRoomSettingsTab extends React.Component<IProps, IState> {
|
||||
public constructor(props: IProps, context: any) {
|
||||
super(props, context);
|
||||
public constructor(props: IProps) {
|
||||
super(props);
|
||||
|
||||
const msc3946ProcessDynamicPredecessor = SettingsStore.getValue("feature_dynamic_room_predecessors");
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ export default class RolesRoomSettingsTab extends React.Component<IProps> {
|
|||
const plContent = plEvent ? plEvent.getContent() || {} : {};
|
||||
const canChangeLevels = room.currentState.mayClientSendStateEvent(EventType.RoomPowerLevels, client);
|
||||
|
||||
const plEventsToLabels = {
|
||||
const plEventsToLabels: Record<EventType | string, string> = {
|
||||
// These will be translated for us later.
|
||||
[EventType.RoomAvatar]: isSpaceRoom ? _td("Change space avatar") : _td("Change room avatar"),
|
||||
[EventType.RoomName]: isSpaceRoom ? _td("Change space name") : _td("Change room name"),
|
||||
|
|
|
@ -58,7 +58,7 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
|
|||
public static contextType = MatrixClientContext;
|
||||
public context!: React.ContextType<typeof MatrixClientContext>;
|
||||
|
||||
public constructor(props, context) {
|
||||
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||
super(props, context);
|
||||
|
||||
const state = context.getRoom(this.props.roomId).currentState;
|
||||
|
|
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ChangeEvent } from "react";
|
||||
|
||||
import { _t } from "../../../../../languageHandler";
|
||||
import SdkConfig from "../../../../../SdkConfig";
|
||||
|
@ -116,7 +116,7 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
|
|||
<Field
|
||||
className="mx_AppearanceUserSettingsTab_systemFont"
|
||||
label={SettingsStore.getDisplayName("systemFont")}
|
||||
onChange={(value) => {
|
||||
onChange={(value: ChangeEvent<HTMLInputElement>) => {
|
||||
this.setState({
|
||||
systemFont: value.target.value,
|
||||
});
|
||||
|
|
|
@ -21,6 +21,7 @@ import { SERVICE_TYPES } from "matrix-js-sdk/src/service-types";
|
|||
import { IThreepid } from "matrix-js-sdk/src/@types/threepids";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { IDelegatedAuthConfig, M_AUTHENTICATION } from "matrix-js-sdk/src/matrix";
|
||||
import { MatrixError } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { _t } from "../../../../../languageHandler";
|
||||
import ProfileSettings from "../../ProfileSettings";
|
||||
|
@ -34,7 +35,7 @@ import PlatformPeg from "../../../../../PlatformPeg";
|
|||
import { MatrixClientPeg } from "../../../../../MatrixClientPeg";
|
||||
import Modal from "../../../../../Modal";
|
||||
import dis from "../../../../../dispatcher/dispatcher";
|
||||
import { Policies, Service, startTermsFlow } from "../../../../../Terms";
|
||||
import { Service, ServicePolicyPair, startTermsFlow } from "../../../../../Terms";
|
||||
import IdentityAuthClient from "../../../../../IdentityAuthClient";
|
||||
import { abbreviateUrl } from "../../../../../utils/UrlUtils";
|
||||
import { getThreepidsWithBindStatus } from "../../../../../boundThreepids";
|
||||
|
@ -68,10 +69,7 @@ interface IState {
|
|||
requiredPolicyInfo: {
|
||||
// This object is passed along to a component for handling
|
||||
hasTerms: boolean;
|
||||
policiesAndServices: {
|
||||
service: Service;
|
||||
policies: Policies;
|
||||
}[]; // From the startTermsFlow callback
|
||||
policiesAndServices: ServicePolicyPair[]; // From the startTermsFlow callback
|
||||
agreedUrls: string[]; // From the startTermsFlow callback
|
||||
resolve: (values: string[]) => void; // Promise resolve function for startTermsFlow callback
|
||||
};
|
||||
|
@ -258,7 +256,7 @@ export default class GeneralUserSettingsTab extends React.Component<IProps, ISta
|
|||
PlatformPeg.get()?.setSpellCheckEnabled(spellCheckEnabled);
|
||||
};
|
||||
|
||||
private onPasswordChangeError = (err): void => {
|
||||
private onPasswordChangeError = (err: { error: string } & MatrixError): void => {
|
||||
// TODO: Figure out a design that doesn't involve replacing the current dialog
|
||||
let errMsg = err.error || err.message || "";
|
||||
if (err.httpStatus === 403) {
|
||||
|
|
|
@ -42,7 +42,7 @@ interface IState {
|
|||
}
|
||||
|
||||
export default class HelpUserSettingsTab extends React.Component<IProps, IState> {
|
||||
public constructor(props) {
|
||||
public constructor(props: IProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
|
@ -80,7 +80,7 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
|
|||
};
|
||||
}
|
||||
|
||||
private onClearCacheAndReload = (e): void => {
|
||||
private onClearCacheAndReload = (): void => {
|
||||
if (!PlatformPeg.get()) return;
|
||||
|
||||
// Dev note: please keep this log line, it's useful when troubleshooting a MatrixClient suddenly
|
||||
|
@ -94,11 +94,11 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
|
|||
});
|
||||
};
|
||||
|
||||
private onBugReport = (e): void => {
|
||||
private onBugReport = (): void => {
|
||||
Modal.createDialog(BugReportDialog, {});
|
||||
};
|
||||
|
||||
private onStartBotChat = (e): void => {
|
||||
private onStartBotChat = (): void => {
|
||||
this.props.closeSettingsFn();
|
||||
createRoom({
|
||||
dmUserId: SdkConfig.get("welcome_user_id"),
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
|
||||
import React from "react";
|
||||
|
||||
import { ICategory, CATEGORIES, CategoryName } from "../../../../../accessibility/KeyboardShortcuts";
|
||||
import { ICategory, CATEGORIES, CategoryName, KeyBindingAction } from "../../../../../accessibility/KeyboardShortcuts";
|
||||
import SdkConfig from "../../../../../SdkConfig";
|
||||
import { _t } from "../../../../../languageHandler";
|
||||
import {
|
||||
|
@ -27,7 +27,7 @@ import {
|
|||
import { KeyboardShortcut } from "../../KeyboardShortcut";
|
||||
|
||||
interface IKeyboardShortcutRowProps {
|
||||
name: string;
|
||||
name: KeyBindingAction;
|
||||
}
|
||||
|
||||
// Filter out the labs section if labs aren't enabled.
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ChangeEvent, SyntheticEvent } from "react";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import { _t } from "../../../../../languageHandler";
|
||||
|
@ -36,7 +36,7 @@ interface IState {
|
|||
}
|
||||
|
||||
export default class MjolnirUserSettingsTab extends React.Component<{}, IState> {
|
||||
public constructor(props) {
|
||||
public constructor(props: {}) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
|
@ -46,15 +46,15 @@ export default class MjolnirUserSettingsTab extends React.Component<{}, IState>
|
|||
};
|
||||
}
|
||||
|
||||
private onPersonalRuleChanged = (e): void => {
|
||||
private onPersonalRuleChanged = (e: ChangeEvent<HTMLInputElement>): void => {
|
||||
this.setState({ newPersonalRule: e.target.value });
|
||||
};
|
||||
|
||||
private onNewListChanged = (e): void => {
|
||||
private onNewListChanged = (e: ChangeEvent<HTMLInputElement>): void => {
|
||||
this.setState({ newList: e.target.value });
|
||||
};
|
||||
|
||||
private onAddPersonalRule = async (e): Promise<void> => {
|
||||
private onAddPersonalRule = async (e: SyntheticEvent): Promise<void> => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
|
@ -80,7 +80,7 @@ export default class MjolnirUserSettingsTab extends React.Component<{}, IState>
|
|||
}
|
||||
};
|
||||
|
||||
private onSubscribeList = async (e): Promise<void> => {
|
||||
private onSubscribeList = async (e: SyntheticEvent): Promise<void> => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
|
|||
// Autocomplete delay (niche text box)
|
||||
];
|
||||
|
||||
public constructor(props) {
|
||||
public constructor(props: IProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue