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
|
@ -59,7 +59,7 @@ export function getSlashCommand(model: EditorModel): [Command | undefined, strin
|
|||
|
||||
export async function runSlashCommand(
|
||||
cmd: Command,
|
||||
args: string,
|
||||
args: string | undefined,
|
||||
roomId: string,
|
||||
threadId: string | null,
|
||||
): Promise<[content: IContent | null, success: boolean]> {
|
||||
|
|
|
@ -45,7 +45,7 @@ import { Caret } from "./caret";
|
|||
*/
|
||||
|
||||
type TransformCallback = (caretPosition: DocumentPosition, inputType: string, diff: IDiff) => number | void;
|
||||
type UpdateCallback = (caret: Caret, inputType?: string, diff?: IDiff) => void;
|
||||
type UpdateCallback = (caret?: Caret, inputType?: string, diff?: IDiff) => void;
|
||||
type ManualTransformCallback = () => Caret;
|
||||
|
||||
export default class EditorModel {
|
||||
|
@ -252,7 +252,7 @@ export default class EditorModel {
|
|||
}
|
||||
|
||||
private onAutoComplete = ({ replaceParts, close }: ICallback): void => {
|
||||
let pos;
|
||||
let pos: DocumentPosition | undefined;
|
||||
if (replaceParts) {
|
||||
this._parts.splice(this.autoCompletePartIdx, this.autoCompletePartCount, ...replaceParts);
|
||||
this.autoCompletePartCount = replaceParts.length;
|
||||
|
@ -380,13 +380,15 @@ export default class EditorModel {
|
|||
// reset it to insert as first part
|
||||
index = 0;
|
||||
}
|
||||
while (str) {
|
||||
const newPart = this._partCreator.createPartForInput(str, index, inputType);
|
||||
const oldStr = str;
|
||||
str = newPart.appendUntilRejected(str, inputType);
|
||||
if (str === oldStr) {
|
||||
|
||||
let it: string | undefined = str;
|
||||
while (it) {
|
||||
const newPart = this._partCreator.createPartForInput(it, index, inputType);
|
||||
const oldStr = it;
|
||||
it = newPart.appendUntilRejected(it, inputType);
|
||||
if (it === oldStr) {
|
||||
// nothing changed, break out of this infinite loop and log an error
|
||||
console.error(`Failed to update model for input (str ${str}) (type ${inputType})`);
|
||||
console.error(`Failed to update model for input (str ${it}) (type ${inputType})`);
|
||||
break;
|
||||
}
|
||||
this.insertPart(index, newPart);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue