refactor(editor): cleanup ts-expect-error (#9369)

This commit is contained in:
Saul-Mirone
2024-12-27 05:14:23 +00:00
parent 908e3efd12
commit 2b27d62b0e
35 changed files with 84 additions and 90 deletions

View File

@@ -34,7 +34,7 @@ export const insertLinkByQuickSearchCommand: Command<
// add normal link;
if ('externalUrl' in result) {
// @ts-expect-error TODO: fix after bookmark refactor
// @ts-expect-error FIXME: fix after bookmark refactor
std.command.exec('insertBookmark', { url: result.externalUrl });
return {
flavour: 'affine:bookmark',

View File

@@ -242,7 +242,7 @@ export async function copyImageBlob(
}
try {
// @ts-expect-error FIXME: ts error
// @ts-expect-error FIXME: BS-2239
if (window.apis?.clipboard?.copyAsImageFromString) {
const dataURL = await convertToString(blob);
if (!dataURL)
@@ -250,7 +250,7 @@ export async function copyImageBlob(
ErrorCode.DefaultRuntimeError,
'Cant convert a blob to data URL.'
);
// @ts-expect-error FIXME: ts error
// @ts-expect-error FIXME: BS-2239
await window.apis.clipboard?.copyAsImageFromString(dataURL);
} else {
// DOMException: Type image/jpeg not supported on write.

View File

@@ -44,7 +44,7 @@ export class LatexBlockComponent extends CaptionedBlockComponent<LatexBlockModel
const latex = this.model.latex$.value;
katexContainer.replaceChildren();
// @ts-expect-error FIXME: ts error
// @ts-expect-error lit hack won't fix
delete katexContainer['_$litPart$'];
if (latex.length === 0) {
@@ -60,7 +60,7 @@ export class LatexBlockComponent extends CaptionedBlockComponent<LatexBlockModel
});
} catch {
katexContainer.replaceChildren();
// @ts-expect-error FIXME: ts error
// @ts-expect-error lit hack won't fix
delete katexContainer['_$litPart$'];
render(
html`<span class="latex-block-error-placeholder"

View File

@@ -21,7 +21,7 @@ export function forwardDelete(std: BlockStdScope) {
const ignoreForwardDeleteFlavourList: BlockSuite.Flavour[] = [
'affine:attachment',
'affine:bookmark',
// @ts-expect-error TODO: should be fixed after database model is migrated to affine-models
// @ts-expect-error FIXME: should be fixed after database model is migrated to affine-models
'affine:database',
'affine:code',
'affine:image',

View File

@@ -86,7 +86,7 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {
return true;
}
// @ts-expect-error TODO: should be fixed after database model is migrated to affine-models
// @ts-expect-error FIXME: should be fixed after database model is migrated to affine-models
if (matchFlavours(parent, ['affine:database'])) {
doc.deleteBlock(model);
focusTextModel(editorHost.std, prevBlock.id, prevBlock.text?.yText.length);

View File

@@ -482,7 +482,7 @@ export const LatexExtension = InlineMarkdownExtension({
if (!latexBlock || latexBlock.flavour !== 'affine:latex') return;
//FIXME(@Flrande): wait for refactor
// @ts-expect-error FIXME: ts error
// @ts-expect-error BS-2241
latexBlock.toggleEditor();
})
.catch(console.error);

View File

@@ -58,10 +58,7 @@ export class AffineLatexNode extends SignalWatcher(
gap: 10px;
border-radius: 4px;
background: ${
// @ts-expect-error FIXME: ts error
unsafeCSSVarV2('label/red')
};
background: ${unsafeCSSVarV2('chip/label/red')};
color: ${unsafeCSSVarV2('text/highlight/fg/red')};
font-family: Inter;
@@ -126,7 +123,7 @@ export class AffineLatexNode extends SignalWatcher(
if (!latexContainer) return;
latexContainer.replaceChildren();
// @ts-expect-error FIXME: ts error
// @ts-expect-error lit hack won't fix
delete latexContainer['_$litPart$'];
if (latex.length === 0) {
@@ -142,7 +139,7 @@ export class AffineLatexNode extends SignalWatcher(
});
} catch {
latexContainer.replaceChildren();
// @ts-expect-error FIXME: ts error
// @ts-expect-error lit hack won't fix
delete latexContainer['_$litPart$'];
render(
html`<span class="error-placeholder">Error equation</span>`,

View File

@@ -110,8 +110,7 @@ const compareAny = (a: unknown, b: unknown) => {
if (!b) {
return Compare.LT;
}
// @ts-expect-error FIXME: ts error
return a - b;
return Number(a) - Number(b);
};
const compareTag = (type: DataTypeOf<typeof t.tag>, a: unknown, b: unknown) => {

View File

@@ -499,10 +499,9 @@ export const mindmapStyleGetters: Record<MindmapStyle, MindmapStyleGetter> = {
export const applyNodeStyle = (node: MindmapNode, nodeStyle: NodeStyle) => {
Object.entries(nodeStyle).forEach(([key, value]) => {
// @ts-expect-error FIXME: ts error
if (!isEqual(node.element[key], value)) {
// @ts-expect-error FIXME: ts error
node.element[key] = value;
const element = node.element as unknown as Record<string, unknown>;
if (!isEqual(element[key], value)) {
element[key] = value;
}
});
};