mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-18 18:41:52 +08:00
refactor(editor): cleanup ts-expect-error (#9369)
This commit is contained in:
+1
-1
@@ -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',
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+3
-6
@@ -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>`,
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -175,8 +175,8 @@ export const replaceIdMiddleware: JobMiddleware = ({ slots, collection }) => {
|
||||
break;
|
||||
}
|
||||
case 'group': {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
const json = value.children.json as Record<string, unknown>;
|
||||
const json = (value.children as Record<string, unknown>)
|
||||
.json as Record<string, unknown>;
|
||||
Object.entries(json).forEach(([key, value]) => {
|
||||
if (idMap.has(key)) {
|
||||
delete json[key];
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
type BlockHtmlAdapterMatcher,
|
||||
HastUtils,
|
||||
} from '@blocksuite/affine-shared/adapters';
|
||||
import type { DeltaInsert } from '@blocksuite/inline';
|
||||
import { nanoid } from '@blocksuite/store';
|
||||
import { bundledLanguagesInfo, codeToHast } from 'shiki';
|
||||
|
||||
@@ -74,16 +75,15 @@ export const codeBlockHtmlAdapterMatcher: BlockHtmlAdapterMatcher = {
|
||||
)?.id ?? 'text')
|
||||
: 'text';
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
const text = o.node.props.text.delta as DeltaInsert[];
|
||||
const text = (o.node.props.text as Record<string, unknown>)
|
||||
.delta as DeltaInsert[];
|
||||
const code = text.map(delta => delta.insert).join('');
|
||||
const hast = await codeToHast(code, {
|
||||
lang: matchedLang,
|
||||
theme: 'light-plus',
|
||||
});
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
walkerContext.openNode(hast, 'children').closeNode();
|
||||
walkerContext.openNode(hast as never, 'children').closeNode();
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ export function cloneDeep<T>(obj: T): T {
|
||||
seen.set(val, copy);
|
||||
|
||||
Object.keys(val).forEach(key => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error deep clone
|
||||
copy[key] = clone(val[key]);
|
||||
});
|
||||
|
||||
|
||||
@@ -319,8 +319,7 @@ export class EdgelessChangeTextMenu extends WithDisposable(LitElement) {
|
||||
|
||||
const key = this.elementType === 'connector' ? 'labelStyle' : 'color';
|
||||
this.elements.forEach(ele => {
|
||||
// @ts-expect-error: FIXME
|
||||
ele[event.type === 'start' ? 'stash' : 'pop'](key);
|
||||
ele[event.type === 'start' ? 'stash' : 'pop'](key as 'color');
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ export const edgelessToBlob = async (
|
||||
};
|
||||
|
||||
export const writeImageBlobToClipboard = async (blob: Blob) => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error FIXME: BS-2239
|
||||
if (window.apis?.clipboard?.copyAsImageFromString) {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error FIXME: BS-2239
|
||||
await window.apis.clipboard?.copyAsImageFromString(blob);
|
||||
} else {
|
||||
await navigator.clipboard.write([new ClipboardItem({ [blob.type]: blob })]);
|
||||
|
||||
@@ -13,9 +13,9 @@ export function setObjectPropMeta(
|
||||
prop: string | symbol,
|
||||
val: unknown
|
||||
) {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
target[symbol] = target[symbol] ?? {};
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
target[symbol][prop] = val;
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@ export function getObjectPropMeta(
|
||||
prop?: string | symbol
|
||||
) {
|
||||
if (prop) {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
return target[symbol]?.[prop] ?? null;
|
||||
}
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
return target[symbol] ?? {};
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ export function updateDerivedProps(
|
||||
const decoratorState = getDecoratorState(receiver.surface);
|
||||
decoratorState.deriving = true;
|
||||
keys(derivedProps).forEach(key => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
receiver[key] = derivedProps[key];
|
||||
});
|
||||
decoratorState.deriving = false;
|
||||
|
||||
@@ -62,10 +62,10 @@ export function startObserve(
|
||||
) {
|
||||
const proto = Object.getPrototypeOf(receiver);
|
||||
const observeFn = getObserveMeta(proto, prop as string)!;
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
const observerDisposable = receiver[observerDisposableSymbol] ?? {};
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
receiver[observerDisposableSymbol] = observerDisposable;
|
||||
|
||||
if (observerDisposable[prop]) {
|
||||
@@ -114,7 +114,7 @@ export function initializeObservers(
|
||||
});
|
||||
|
||||
receiver['_disposable'].add(() => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
Object.values(receiver[observerDisposableSymbol] ?? {}).forEach(dispose =>
|
||||
(dispose as () => void)()
|
||||
);
|
||||
|
||||
@@ -277,7 +277,7 @@ export abstract class GfxPrimitiveElementModel<
|
||||
|
||||
const value = this._stashed.get(prop);
|
||||
this._stashed.delete(prop);
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
delete this[prop];
|
||||
|
||||
if (getFieldPropsSet(this).has(prop as string)) {
|
||||
|
||||
@@ -126,14 +126,14 @@ export abstract class GfxLocalElementModel implements GfxCompatibleInterface {
|
||||
this._local.delete('deserializedXYWH');
|
||||
}
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
const oldValue = target[prop as string];
|
||||
|
||||
if (oldValue === value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
target[prop as string] = value;
|
||||
|
||||
if (!this._props.has(prop)) {
|
||||
@@ -158,7 +158,7 @@ export abstract class GfxLocalElementModel implements GfxCompatibleInterface {
|
||||
},
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-constructor-return
|
||||
// oxlint-disable-next-line no-constructor-return
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
||||
|
||||
Object.keys(rest).forEach(key => {
|
||||
if (props[key] !== undefined) {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
elementModel.model[key] = props[key];
|
||||
}
|
||||
});
|
||||
@@ -177,7 +177,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
||||
state.skipField = options.skipFieldInit ?? false;
|
||||
|
||||
let mounted = false;
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
Ctor['_decoratorState'] = state;
|
||||
|
||||
const elementModel = new Ctor({
|
||||
@@ -188,7 +188,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
||||
onChange: payload => mounted && options.onChange({ id, ...payload }),
|
||||
}) as GfxPrimitiveElementModel;
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
delete Ctor['_decoratorState'];
|
||||
state.creating = false;
|
||||
state.skipField = false;
|
||||
@@ -364,7 +364,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
||||
{
|
||||
const group = this.getGroup(payload.id);
|
||||
if (group) {
|
||||
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
||||
// oxlint-disable-next-line unicorn/prefer-dom-node-remove
|
||||
group.removeChild(payload.model as GfxModel);
|
||||
}
|
||||
}
|
||||
@@ -385,7 +385,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
||||
throw new Error(`Invalid element type: ${type}`);
|
||||
}
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
return (ctor.propsToY ?? GfxPrimitiveElementModel.propsToY)(props);
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
||||
|
||||
const id = nanoid();
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
props.id = id;
|
||||
|
||||
const elementModel = this._createElementFromProps(props, {
|
||||
@@ -502,7 +502,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
||||
// oxlint-disable-next-line unicorn/prefer-dom-node-remove
|
||||
group?.removeChild(element as GfxModel);
|
||||
|
||||
this.elements.getValue()!.delete(id);
|
||||
@@ -612,7 +612,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
||||
props as Record<string, unknown>
|
||||
) as T;
|
||||
Object.entries(props).forEach(([key, value]) => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
elementModel[key] = value;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -129,7 +129,7 @@ export class ToolController extends GfxExtension {
|
||||
});
|
||||
|
||||
get currentTool$() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
// oxlint-disable-next-line typescript/no-this-alias
|
||||
const self = this;
|
||||
|
||||
return {
|
||||
@@ -143,7 +143,7 @@ export class ToolController extends GfxExtension {
|
||||
}
|
||||
|
||||
get currentToolOption$() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
// oxlint-disable-next-line typescript/no-this-alias
|
||||
const self = this;
|
||||
|
||||
return {
|
||||
@@ -475,7 +475,7 @@ export class ToolController extends GfxExtension {
|
||||
};
|
||||
|
||||
this.std.provider.getAll(ToolIdentifier).forEach(tool => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
tool['eventTarget'] = eventTarget;
|
||||
this._register(tool);
|
||||
});
|
||||
|
||||
@@ -133,7 +133,7 @@ export function toGfxBlockComponent<
|
||||
WidgetName extends string,
|
||||
B extends typeof BlockComponent<Model, Service, WidgetName>,
|
||||
>(CustomBlock: B) {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
return class extends CustomBlock {
|
||||
[GfxElementSymbol] = true;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ describe('isEqual', () => {
|
||||
)
|
||||
).toBe(true);
|
||||
expect(isEqual({}, { foo: 1 })).toBe(false);
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(isEqual({ foo: 1 }, {})).toBe(false);
|
||||
});
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('isEqual', () => {
|
||||
bigint: 110101195306153019n,
|
||||
};
|
||||
expect(isEqual(nested, nested)).toBe(true);
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(isEqual({ foo: [] }, { foo: '' })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -114,9 +114,9 @@ export const debounce = <T extends (...args: any[]) => void>(
|
||||
};
|
||||
|
||||
export async function nextTick() {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error check window.scheduler
|
||||
if ('scheduler' in window && 'yield' in window.scheduler) {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error check window.scheduler.yield
|
||||
return window.scheduler.yield();
|
||||
} else if (typeof requestIdleCallback !== 'undefined') {
|
||||
return new Promise(resolve => requestIdleCallback(resolve));
|
||||
|
||||
@@ -162,7 +162,7 @@ export async function assertSelection(
|
||||
([richTextIndex]) => {
|
||||
const richText =
|
||||
document?.querySelectorAll('test-rich-text')[richTextIndex];
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error getInlineRange
|
||||
const inlineEditor = richText.inlineEditor;
|
||||
return inlineEditor?.getInlineRange();
|
||||
},
|
||||
|
||||
@@ -36,7 +36,7 @@ const spaceMetaId = 'meta';
|
||||
function serializCollection(doc: BlockSuiteDoc): Record<string, any> {
|
||||
const spaces = {};
|
||||
doc.spaces.forEach((subDoc, key) => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
spaces[key] = subDoc.toJSON();
|
||||
});
|
||||
const json = doc.toJSON();
|
||||
@@ -103,7 +103,7 @@ describe('basic', () => {
|
||||
|
||||
assert.equal(collection.isEmpty, false);
|
||||
assert.equal(typeof actualDoc.createDate, 'number');
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
delete actualDoc.createDate;
|
||||
|
||||
assert.deepEqual(actual, {
|
||||
|
||||
@@ -177,7 +177,7 @@ test('always get latest value in onChange', () => {
|
||||
|
||||
let value: unknown;
|
||||
rootModel.propsUpdated.on(({ key }) => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
value = rootModel[key];
|
||||
});
|
||||
|
||||
|
||||
@@ -96,23 +96,23 @@ test('snapshot to model', async () => {
|
||||
});
|
||||
expect(model.flavour).toBe(rootModel.flavour);
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(model.props.title).toBeInstanceOf(Text);
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
map.set('title', model.props.title.yText);
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(model.props.title.toString()).toBe('doc title');
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(model.props.style).toEqual({
|
||||
color: 'red',
|
||||
});
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(model.props.count).toBe(3);
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(model.props.items).toMatchObject([
|
||||
{
|
||||
id: 0,
|
||||
@@ -125,7 +125,7 @@ test('snapshot to model', async () => {
|
||||
},
|
||||
]);
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
model.props.items.forEach((item, index) => {
|
||||
expect(item.content).toBeInstanceOf(Text);
|
||||
const key = `item:${index}:content`;
|
||||
|
||||
@@ -49,11 +49,11 @@ describe('blocksuite yjs', () => {
|
||||
|
||||
proxy.obj2 = { foo: 2, bar: { num: 3 } };
|
||||
expect(map.get('obj2')).toBeInstanceOf(Y.Map);
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(map.get('obj2').get('bar').get('num')).toBe(3);
|
||||
|
||||
proxy.obj2.bar.str = 'hello';
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(map.get('obj2').get('bar').get('str')).toBe('hello');
|
||||
|
||||
proxy.obj3 = {};
|
||||
@@ -105,7 +105,7 @@ describe('blocksuite yjs', () => {
|
||||
|
||||
proxy.inner.native.setValue(['hello', 'world', 'foo']);
|
||||
expect(native.getValue()).toEqual(['hello', 'world', 'foo']);
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(map.get('inner').get('native').get('value')).toEqual([
|
||||
'hello',
|
||||
'world',
|
||||
@@ -114,10 +114,10 @@ describe('blocksuite yjs', () => {
|
||||
|
||||
const native2 = new Boxed(0);
|
||||
proxy.inner.native2 = native2;
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(map.get('inner').get('native2').get('value')).toBe(0);
|
||||
native2.setValue(1);
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
expect(map.get('inner').get('native2').get('value')).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -150,7 +150,7 @@ function MagicProps(): {
|
||||
|
||||
const modelLabel = Symbol('model_label');
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error allow magic props
|
||||
export class BlockModel<
|
||||
Props extends object = object,
|
||||
PropsSignal extends object = SignaledProps<Props>,
|
||||
|
||||
@@ -46,12 +46,12 @@ export class SyncController {
|
||||
const keyName = key.replace('prop:', '');
|
||||
const proxy = this._getPropsProxy(keyName, value);
|
||||
this._byPassUpdate(() => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error allow magic props
|
||||
this.model[keyName] = proxy;
|
||||
const signalKey = `${keyName}$`;
|
||||
this._mutex(() => {
|
||||
if (signalKey in this.model) {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error allow magic props
|
||||
this.model[signalKey].value = y2Native(value);
|
||||
}
|
||||
});
|
||||
@@ -62,10 +62,10 @@ export class SyncController {
|
||||
if (type.action === 'delete') {
|
||||
const keyName = key.replace('prop:', '');
|
||||
this._byPassUpdate(() => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error allow magic props
|
||||
delete this.model[keyName];
|
||||
if (`${keyName}$` in this.model) {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error allow magic props
|
||||
this.model[`${keyName}$`].value = undefined;
|
||||
}
|
||||
});
|
||||
@@ -136,7 +136,7 @@ export class SyncController {
|
||||
const value = data.value;
|
||||
if (!this.model) return;
|
||||
_mutex(() => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error allow magic props
|
||||
this.model[key] = value;
|
||||
});
|
||||
});
|
||||
@@ -208,7 +208,7 @@ export class SyncController {
|
||||
|
||||
function setValue(target: BlockModel, p: string, value: unknown) {
|
||||
_mutex(() => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error allow magic props
|
||||
target[`${p}$`].value = value;
|
||||
});
|
||||
}
|
||||
@@ -222,7 +222,7 @@ export class SyncController {
|
||||
const signalKey = `${name}$`;
|
||||
if (signalKey in this.model) {
|
||||
this._mutex(() => {
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error allow magic props
|
||||
this.model[signalKey].value = this.model[name];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export function syncBlockProps(
|
||||
if (SYS_KEYS.has(key)) return;
|
||||
if (value === undefined) return;
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error allow props
|
||||
model[key] = value;
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ export function syncBlockProps(
|
||||
return;
|
||||
}
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error allow props
|
||||
model[key] = native2Y(value);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ function renderToImageData(index: number, scale: number) {
|
||||
bitmap.fill(0, 0, width, height);
|
||||
page.render(bitmap, 0, 0, width, height, 0, flags);
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
const data = new Uint8ClampedArray(bitmap.toUint8Array());
|
||||
|
||||
bitmap.close();
|
||||
|
||||
@@ -38,12 +38,12 @@ export const devtoolsFormatter: typeof window.devtoolsFormatters = [
|
||||
if ('flavour' in (obj as BlockModel) && 'yBlock' in (obj as BlockModel)) {
|
||||
globalUtils.assertType<BlockModel>(obj);
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
const { props } = obj.page._blockTree.getBlock(obj.id)._parseYBlock();
|
||||
|
||||
const propsArr = Object.entries(props).flatMap(([key]) => {
|
||||
return [
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error ignore
|
||||
...toStyledEntry(key, obj[key]),
|
||||
['div', {}, ''],
|
||||
] as HTMLTemplate[];
|
||||
|
||||
@@ -14,7 +14,7 @@ const env =
|
||||
: {};
|
||||
const importIdentifier = '__ $BLOCKSUITE_EDITOR$ __';
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error check global identifier
|
||||
if (env[importIdentifier] === true) {
|
||||
// https://github.com/yjs/yjs/issues/438
|
||||
console.error(
|
||||
@@ -22,5 +22,5 @@ if (env[importIdentifier] === true) {
|
||||
);
|
||||
}
|
||||
|
||||
// @ts-expect-error FIXME: ts error
|
||||
// @ts-expect-error set global identifier
|
||||
env[importIdentifier] = true;
|
||||
|
||||
Reference in New Issue
Block a user