Skip to content

Commit 0f24095

Browse files
committed
Remove unnecessary expect error directives
1 parent b4baafd commit 0f24095

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

blots/scroll.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@ import {
77
Registry,
88
} from 'parchment';
99
import { Blot, Parent } from 'parchment/dist/typings/blot/abstract/blot';
10-
import Delta from 'quill-delta';
1110
import Emitter, { EmitterSource } from '../core/emitter';
1211
import Block, { BlockEmbed } from './block';
1312
import Break from './break';
1413
import Container from './container';
1514

16-
function isLine(blot: Blot): blot is Block | BlockEmbed {
15+
function isLine(blot: unknown): blot is Block | BlockEmbed {
1716
return blot instanceof Block || blot instanceof BlockEmbed;
1817
}
1918

2019
interface UpdatableEmbed {
21-
updateContent(change: Delta): void;
20+
updateContent(change: unknown): void;
2221
}
2322

2423
function isUpdatable(blot: Blot): blot is Blot & UpdatableEmbed {
@@ -123,12 +122,11 @@ class Scroll extends ScrollBlot {
123122
this.optimize();
124123
}
125124

126-
insertBefore(blot, ref) {
125+
insertBefore(blot: Blot, ref?: Blot) {
127126
if (blot.statics.scope === Scope.INLINE_BLOT) {
128-
// @ts-expect-error Currently the type is not enforced
129-
const wrapper: Parent = this.scroll.create(
127+
const wrapper = this.scroll.create(
130128
this.statics.defaultChild.blotName,
131-
);
129+
) as Parent;
132130
wrapper.appendChild(blot);
133131
super.insertBefore(wrapper, ref);
134132
} else {
@@ -194,17 +192,17 @@ class Scroll extends ScrollBlot {
194192
}
195193
}
196194

197-
path(index) {
195+
path(index: number) {
198196
return super.path(index).slice(1); // Exclude self
199197
}
200198

201199
remove() {
202200
// Never remove self
203201
}
204202

205-
update(source?: EmitterSource);
206-
update(mutations?: MutationRecord[]);
207-
update(mutations?: MutationRecord[] | EmitterSource) {
203+
update(source?: EmitterSource): void;
204+
update(mutations?: MutationRecord[]): void;
205+
update(mutations?: MutationRecord[] | EmitterSource): void {
208206
if (this.batch) {
209207
if (Array.isArray(mutations)) {
210208
this.batch = this.batch.concat(mutations);
@@ -231,7 +229,7 @@ class Scroll extends ScrollBlot {
231229
}
232230
}
233231

234-
updateEmbedAt(index, key, change) {
232+
updateEmbedAt(index: number, key: string, change: unknown) {
235233
// Currently it only supports top-level embeds (BlockEmbed).
236234
// We can update `ParentBlot` in parchment to support inline embeds.
237235
const [blot] = this.descendant(b => b instanceof BlockEmbed, index);

formats/table.ts

+24-19
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class TableCell extends Block {
2424
return undefined;
2525
}
2626

27+
next: this | null;
28+
2729
cellOffset() {
2830
if (this.parent) {
2931
return this.parent.children.indexOf(this);
@@ -56,15 +58,17 @@ class TableCell extends Block {
5658
}
5759

5860
class TableRow extends Container {
61+
static blotName = 'table-row';
62+
static tagName = 'TR';
63+
64+
children: LinkedList<TableCell>;
65+
next: this | null;
66+
5967
checkMerge() {
6068
if (super.checkMerge() && this.next.children.head != null) {
61-
// @ts-expect-error all children are table cells
6269
const thisHead = this.children.head.formats();
63-
// @ts-expect-error all children are table cells
6470
const thisTail = this.children.tail.formats();
65-
// @ts-expect-error all children are table cells
6671
const nextHead = this.next.children.head.formats();
67-
// @ts-expect-error all children are table cells
6872
const nextTail = this.next.children.tail.formats();
6973
return (
7074
thisHead.table === thisTail.table &&
@@ -78,10 +82,9 @@ class TableRow extends Container {
7882
optimize(...args) {
7983
// @ts-expect-error
8084
super.optimize(...args);
81-
(this.children as LinkedList<TableCell>).forEach(child => {
85+
this.children.forEach(child => {
8286
if (child.next == null) return;
8387
const childFormats = child.formats();
84-
// @ts-expect-error
8588
const nextFormats = child.next.formats();
8689
if (childFormats.table !== nextFormats.table) {
8790
const next = this.splitAfter(child);
@@ -109,14 +112,20 @@ class TableRow extends Container {
109112
return this.parent && this.parent.parent;
110113
}
111114
}
112-
TableRow.blotName = 'table-row';
113-
TableRow.tagName = 'TR';
114115

115-
class TableBody extends Container {}
116-
TableBody.blotName = 'table-body';
117-
TableBody.tagName = 'TBODY';
116+
class TableBody extends Container {
117+
static blotName = 'table-body';
118+
static tagName = 'TBODY';
119+
120+
children: LinkedList<TableRow>;
121+
}
118122

119123
class TableContainer extends Container {
124+
static blotName = 'table-container';
125+
static tagName = 'TABLE';
126+
127+
children: LinkedList<TableBody>;
128+
120129
balanceCells() {
121130
// @ts-expect-error TODO: fix signature of ParentBlot.descendants
122131
const rows = this.descendants(TableRow) as TableRow[];
@@ -137,16 +146,16 @@ class TableContainer extends Container {
137146
});
138147
}
139148

140-
cells(column) {
149+
cells(column: number) {
141150
return this.rows().map(row => row.children.at(column));
142151
}
143152

144-
deleteColumn(index) {
153+
deleteColumn(index: number) {
145154
// @ts-expect-error
146155
const [body] = this.descendant(TableBody) as TableBody[];
147156
if (body == null || body.children.head == null) return;
148157
body.children.forEach(row => {
149-
const cell = (row as TableRow).children.at(index);
158+
const cell = row.children.at(index);
150159
if (cell != null) {
151160
cell.remove();
152161
}
@@ -157,7 +166,7 @@ class TableContainer extends Container {
157166
// @ts-expect-error
158167
const [body] = this.descendant(TableBody) as TableBody[];
159168
if (body == null || body.children.head == null) return;
160-
(body.children as LinkedList<TableRow>).forEach(row => {
169+
body.children.forEach(row => {
161170
const ref = row.children.at(index);
162171
const value = TableCell.formats(row.children.head.domNode);
163172
const cell = this.scroll.create(TableCell.blotName, value);
@@ -171,7 +180,6 @@ class TableContainer extends Container {
171180
if (body == null || body.children.head == null) return;
172181
const id = tableId();
173182
const row = this.scroll.create(TableRow.blotName) as TableRow;
174-
// @ts-expect-error
175183
body.children.head.children.forEach(() => {
176184
const cell = this.scroll.create(TableCell.blotName, id);
177185
row.appendChild(cell);
@@ -183,12 +191,9 @@ class TableContainer extends Container {
183191
rows() {
184192
const body = this.children.head;
185193
if (body == null) return [];
186-
// @ts-expect-error
187194
return body.children.map(row => row);
188195
}
189196
}
190-
TableContainer.blotName = 'table-container';
191-
TableContainer.tagName = 'TABLE';
192197

193198
TableContainer.allowedChildren = [TableBody];
194199
TableBody.requiredContainer = TableContainer;

0 commit comments

Comments
 (0)