From 34f3e62f725e36d361936814bf382dfe4e96b284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 21 Jul 2021 20:48:50 +0200 Subject: [PATCH] Types! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/@types/svg.d.ts | 2 +- .../views/dialogs/AddressPickerDialog.tsx | 14 +++++++++++--- src/components/views/elements/AddressSelector.tsx | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/@types/svg.d.ts b/src/@types/svg.d.ts index 6247792391..aeb75b2bae 100644 --- a/src/@types/svg.d.ts +++ b/src/@types/svg.d.ts @@ -15,6 +15,6 @@ limitations under the License. */ declare module "*.svg" { - const content: any; + const content: string; export default content; } diff --git a/src/components/views/dialogs/AddressPickerDialog.tsx b/src/components/views/dialogs/AddressPickerDialog.tsx index a3abc15b1b..1a976918bd 100644 --- a/src/components/views/dialogs/AddressPickerDialog.tsx +++ b/src/components/views/dialogs/AddressPickerDialog.tsx @@ -46,6 +46,14 @@ const addressTypeName = { 'email': _td("email address"), }; +interface IResult { + user_id: string; // eslint-disable-line camelcase + room_id?: string; // eslint-disable-line camelcase + name?: string; + display_name?: string; // eslint-disable-line camelcase + avatar_url?: string;// eslint-disable-line camelcase +} + interface IProps { title: string; description?: JSX.Element; @@ -422,7 +430,7 @@ export default class AddressPickerDialog extends React.Component this.processResults(results, query); } - private processResults(results, query: string): void { + private processResults(results: IResult[], query: string): void { const suggestedList = []; results.forEach((result) => { if (result.room_id) { @@ -490,7 +498,7 @@ export default class AddressPickerDialog extends React.Component }); } - private addAddressesToList(addressTexts): IUserAddress[] { + private addAddressesToList(addressTexts: string[]): IUserAddress[] { const selectedList = this.state.selectedList.slice(); let hasError = false; @@ -533,7 +541,7 @@ export default class AddressPickerDialog extends React.Component return hasError ? null : selectedList; } - private async lookupThreepid(medium, address): Promise { + private async lookupThreepid(medium: AddressType, address: string): Promise { let cancelled = false; // Note that we can't safely remove this after we're done // because we don't know that it's the same one, so we just diff --git a/src/components/views/elements/AddressSelector.tsx b/src/components/views/elements/AddressSelector.tsx index 62474097d3..eae82142da 100644 --- a/src/components/views/elements/AddressSelector.tsx +++ b/src/components/views/elements/AddressSelector.tsx @@ -163,7 +163,7 @@ export default class AddressSelector extends React.Component { return addressList; } - private maxSelected(list): number { + private maxSelected(list: IUserAddress[]): number { const listSize = list.length === 0 ? 0 : list.length - 1; const maxSelected = listSize > (this.props.truncateAt - 1) ? (this.props.truncateAt - 1) : listSize; return maxSelected;