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
|
@ -149,7 +149,7 @@ function prefixLines(parts: Part[], prefix: string, pc: PartCreator): void {
|
|||
}
|
||||
|
||||
function parseChildren(n: Node, pc: PartCreator, opts: IParseOptions, mkListItem?: (li: Node) => Part[]): Part[] {
|
||||
let prev;
|
||||
let prev: ChildNode | undefined;
|
||||
return Array.from(n.childNodes).flatMap((c) => {
|
||||
const parsed = parseNode(c, pc, opts, mkListItem);
|
||||
if (parsed.length && prev && (checkBlockNode(prev) || checkBlockNode(c))) {
|
||||
|
|
|
@ -47,7 +47,7 @@ export default class HistoryManager {
|
|||
this.removedSinceLastPush = false;
|
||||
}
|
||||
|
||||
private shouldPush(inputType, diff): boolean {
|
||||
private shouldPush(inputType: string, diff: IDiff): boolean {
|
||||
// right now we can only push a step after
|
||||
// the input has been applied to the model,
|
||||
// so we can't push the state before something happened.
|
||||
|
|
|
@ -272,11 +272,11 @@ export default class EditorModel {
|
|||
};
|
||||
|
||||
private mergeAdjacentParts(): void {
|
||||
let prevPart;
|
||||
let prevPart: Part | undefined;
|
||||
for (let i = 0; i < this._parts.length; ++i) {
|
||||
let part = this._parts[i];
|
||||
const isEmpty = !part.text.length;
|
||||
const isMerged = !isEmpty && prevPart && prevPart.merge(part);
|
||||
const isMerged = !isEmpty && prevPart && prevPart.merge?.(part);
|
||||
if (isEmpty || isMerged) {
|
||||
// remove empty or merged part
|
||||
part = prevPart;
|
||||
|
|
|
@ -70,6 +70,8 @@ interface IBasePart {
|
|||
updateDOMNode(node: Node): void;
|
||||
canUpdateDOMNode(node: Node): boolean;
|
||||
toDOMNode(): Node;
|
||||
|
||||
merge?(part: Part): boolean;
|
||||
}
|
||||
|
||||
interface IPillCandidatePart extends Omit<IBasePart, "type" | "createAutoComplete"> {
|
||||
|
@ -227,7 +229,7 @@ abstract class PlainBasePart extends BasePart {
|
|||
return document.createTextNode(this.text);
|
||||
}
|
||||
|
||||
public merge(part): boolean {
|
||||
public merge(part: Part): boolean {
|
||||
if (part.type === this.type) {
|
||||
this._text = this.text + part.text;
|
||||
return true;
|
||||
|
@ -254,7 +256,7 @@ export class PlainPart extends PlainBasePart implements IBasePart {
|
|||
}
|
||||
|
||||
export abstract class PillPart extends BasePart implements IPillPart {
|
||||
public constructor(public resourceId: string, label) {
|
||||
public constructor(public resourceId: string, label: string) {
|
||||
super(label);
|
||||
}
|
||||
|
||||
|
@ -455,7 +457,7 @@ class AtRoomPillPart extends RoomPillPart {
|
|||
}
|
||||
|
||||
class UserPillPart extends PillPart {
|
||||
public constructor(userId, displayName, private member?: RoomMember) {
|
||||
public constructor(userId: string, displayName: string, private member?: RoomMember) {
|
||||
super(userId, displayName);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ export function needsCaretNodeAfter(part: Part, isLastOfLine: boolean): boolean
|
|||
return !part.acceptsCaret && isLastOfLine;
|
||||
}
|
||||
|
||||
function insertAfter(node: HTMLElement, nodeToInsert: HTMLElement): void {
|
||||
function insertAfter(node: ChildNode, nodeToInsert: ChildNode): void {
|
||||
const next = node.nextSibling;
|
||||
if (next) {
|
||||
node.parentElement!.insertBefore(nodeToInsert, next);
|
||||
|
@ -51,7 +51,7 @@ function createCaretNode(): HTMLElement {
|
|||
return span;
|
||||
}
|
||||
|
||||
function updateCaretNode(node: HTMLElement): void {
|
||||
function updateCaretNode(node: ChildNode): void {
|
||||
// ensure the caret node contains only a zero-width space
|
||||
if (node.textContent !== CARET_NODE_CHAR) {
|
||||
node.textContent = CARET_NODE_CHAR;
|
||||
|
@ -92,7 +92,7 @@ function reconcileLine(lineContainer: ChildNode, parts: Part[]): void {
|
|||
currentNode = isFirst ? lineContainer.firstChild : currentNode!.nextSibling;
|
||||
|
||||
if (needsCaretNodeBefore(part, prevPart)) {
|
||||
if (isCaretNode(currentNode)) {
|
||||
if (isCaretNode(currentNode as Element)) {
|
||||
updateCaretNode(currentNode);
|
||||
currentNode = currentNode.nextSibling;
|
||||
} else {
|
||||
|
@ -115,7 +115,7 @@ function reconcileLine(lineContainer: ChildNode, parts: Part[]): void {
|
|||
}
|
||||
|
||||
if (needsCaretNodeAfter(part, part === lastPart)) {
|
||||
if (isCaretNode(currentNode?.nextSibling)) {
|
||||
if (isCaretNode(currentNode?.nextSibling as Element)) {
|
||||
currentNode = currentNode!.nextSibling;
|
||||
updateCaretNode(currentNode as HTMLElement);
|
||||
} else {
|
||||
|
|
|
@ -77,8 +77,8 @@ export function htmlSerializeFromMdIfNeeded(md: string, { forceHTML = false } =
|
|||
const orig = md;
|
||||
|
||||
if (SettingsStore.getValue("feature_latex_maths")) {
|
||||
const patternNames = ["tex", "latex"];
|
||||
const patternTypes = ["display", "inline"];
|
||||
const patternNames = ["tex", "latex"] as const;
|
||||
const patternTypes = ["display", "inline"] as const;
|
||||
const patternDefaults = {
|
||||
tex: {
|
||||
// detect math with tex delimiters, inline: $...$, display $$...$$
|
||||
|
@ -118,7 +118,7 @@ export function htmlSerializeFromMdIfNeeded(md: string, { forceHTML = false } =
|
|||
patternTypes.forEach(function (patternType) {
|
||||
// get the regex replace pattern from config or use the default
|
||||
const pattern =
|
||||
(((SdkConfig.get("latex_maths_delims") || {})[patternType] || {})["pattern"] || {})[patternName] ||
|
||||
SdkConfig.get("latex_maths_delims")?.[patternType]?.["pattern"]?.[patternName] ||
|
||||
patternDefaults[patternName][patternType];
|
||||
|
||||
md = md.replace(RegExp(pattern, "gms"), function (m, p1, p2) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue