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
|
@ -19,7 +19,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React from "react";
|
||||
import { uniq, sortBy } from "lodash";
|
||||
import { uniq, sortBy, ListIteratee } from "lodash";
|
||||
import EMOTICON_REGEX from "emojibase-regex/emoticon";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
|
||||
|
@ -55,7 +55,11 @@ const SORTED_EMOJI: ISortedEmoji[] = EMOJI.sort((a, b) => {
|
|||
_orderBy: index,
|
||||
}));
|
||||
|
||||
function score(query: string, space: string): number {
|
||||
function score(query: string, space: string[] | string): number {
|
||||
if (Array.isArray(space)) {
|
||||
return Math.min(...space.map((s) => score(query, s)));
|
||||
}
|
||||
|
||||
const index = space.indexOf(query);
|
||||
if (index === -1) {
|
||||
return Infinity;
|
||||
|
@ -113,7 +117,7 @@ export default class EmojiProvider extends AutocompleteProvider {
|
|||
// Do second match with shouldMatchWordsOnly in order to match against 'name'
|
||||
completions = completions.concat(this.nameMatcher.match(matchedString));
|
||||
|
||||
let sorters = [];
|
||||
let sorters: ListIteratee<ISortedEmoji>[] = [];
|
||||
// make sure that emoticons come first
|
||||
sorters.push((c) => score(matchedString, c.emoji.emoticon || ""));
|
||||
|
||||
|
|
|
@ -110,17 +110,14 @@ export default class UserProvider extends AutocompleteProvider {
|
|||
// lazy-load user list into matcher
|
||||
if (!this.users) this.makeUsers();
|
||||
|
||||
let completions = [];
|
||||
const { command, range } = this.getCurrentCommand(rawQuery, selection, force);
|
||||
|
||||
if (!command) return completions;
|
||||
|
||||
const fullMatch = command[0];
|
||||
const fullMatch = command?.[0];
|
||||
// Don't search if the query is a single "@"
|
||||
if (fullMatch && fullMatch !== "@") {
|
||||
// Don't include the '@' in our search query - it's only used as a way to trigger completion
|
||||
const query = fullMatch.startsWith("@") ? fullMatch.substring(1) : fullMatch;
|
||||
completions = this.matcher.match(query, limit).map((user) => {
|
||||
return this.matcher.match(query, limit).map((user) => {
|
||||
const description = UserIdentifierCustomisations.getDisplayUserIdentifier(user.userId, {
|
||||
roomId: this.room.roomId,
|
||||
withDisplayName: true,
|
||||
|
@ -143,7 +140,7 @@ export default class UserProvider extends AutocompleteProvider {
|
|||
};
|
||||
});
|
||||
}
|
||||
return completions;
|
||||
return [];
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
|
@ -152,7 +149,7 @@ export default class UserProvider extends AutocompleteProvider {
|
|||
|
||||
private makeUsers(): void {
|
||||
const events = this.room.getLiveTimeline().getEvents();
|
||||
const lastSpoken = {};
|
||||
const lastSpoken: Record<string, number> = {};
|
||||
|
||||
for (const event of events) {
|
||||
lastSpoken[event.getSender()] = event.getTs();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue