Make more code conform to strict null checks (#10219
* Make more code conform to strict null checks * Fix types * Fix tests * Fix remaining test assertions * Iterate PR
This commit is contained in:
parent
4c79ecf141
commit
76b82b4b2b
130 changed files with 603 additions and 603 deletions
|
@ -27,6 +27,7 @@ import { timeout } from "../utils/promise";
|
|||
import AutocompleteProvider, { ICommand } from "./AutocompleteProvider";
|
||||
import SpaceProvider from "./SpaceProvider";
|
||||
import { TimelineRenderingType } from "../contexts/RoomContext";
|
||||
import { filterBoolean } from "../utils/arrays";
|
||||
|
||||
export interface ISelectionRange {
|
||||
beginning?: boolean; // whether the selection is in the first block of the editor or not
|
||||
|
@ -55,7 +56,7 @@ const PROVIDER_COMPLETION_TIMEOUT = 3000;
|
|||
export interface IProviderCompletions {
|
||||
completions: ICompletion[];
|
||||
provider: AutocompleteProvider;
|
||||
command: ICommand;
|
||||
command: Partial<ICommand>;
|
||||
}
|
||||
|
||||
export default class Autocompleter {
|
||||
|
@ -98,8 +99,8 @@ export default class Autocompleter {
|
|||
);
|
||||
|
||||
// map then filter to maintain the index for the map-operation, for this.providers to line up
|
||||
return completionsList
|
||||
.map((completions, i) => {
|
||||
return filterBoolean(
|
||||
completionsList.map((completions, i) => {
|
||||
if (!completions || !completions.length) return;
|
||||
|
||||
return {
|
||||
|
@ -112,7 +113,7 @@ export default class Autocompleter {
|
|||
*/
|
||||
command: this.providers[i].getCurrentCommand(query, selection, force),
|
||||
};
|
||||
})
|
||||
.filter(Boolean) as IProviderCompletions[];
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import SettingsStore from "../settings/SettingsStore";
|
|||
import { EMOJI, IEmoji, getEmojiFromUnicode } from "../emoji";
|
||||
import { TimelineRenderingType } from "../contexts/RoomContext";
|
||||
import * as recent from "../emojipicker/recent";
|
||||
import { filterBoolean } from "../utils/arrays";
|
||||
|
||||
const LIMIT = 20;
|
||||
|
||||
|
@ -94,7 +95,7 @@ export default class EmojiProvider extends AutocompleteProvider {
|
|||
shouldMatchWordsOnly: true,
|
||||
});
|
||||
|
||||
this.recentlyUsed = Array.from(new Set(recent.get().map(getEmojiFromUnicode).filter(Boolean))) as IEmoji[];
|
||||
this.recentlyUsed = Array.from(new Set(filterBoolean(recent.get().map(getEmojiFromUnicode))));
|
||||
}
|
||||
|
||||
public async getCompletions(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue