You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type Error: Generic type 'Block' requires 3 type arguments #497
I've just been doing something like below for now until there's an update.
const[blocks,setBlocks]=useState<Block<any,any,any>[]>([]);constinsertHelloWorld=(editor: BlockNoteEditor)=>{// Block that the text cursor is currently in.constcurrentBlock: Block<any,any,any>=editor.getTextCursorPosition().block;// New block we want to insert.consthelloWorldBlock: PartialBlock<any,any,any>={type: "paragraph",content: [{type: "text",text: "Hello World",styles: {bold: true}}],};// Inserting the new block after the current one.editor.insertBlocks([helloWorldBlockasany],currentBlock,"after");};
The functionality still works fine just needed to get the error to no throw for me to publish it out to vercel.
Still wrapping my head around this project, hopefully can help contribute in the future as I'm going to heavily use this for other projects too.
For people facing this issue, most of this should be fixable removing the type annotation on the variable declaration. E.g. remove : Block[] in the original example.
When declaring Blocks, you can use as const to help the TS compiler. For example, see
Background: BlockNote is designed to be as type-safe as possible, whilst being extensible. So in BlockNote, you can define your custom schema / types for blocks / inlinecontent / styles, and this will be reflected in the Type System. This is done using generics.
Whilst this is really powerful (you get proper code completion and error checking), sometimes it can be a bit cumbersome. The above tips should help!
In the meantime, I'll also look into the suggestions by @zcf0508 and other ways to make this a bit more easier!
hi there, I'm facing a similar issue in PartialBlock.
here's the issue
Generic type 'PartialBlock' requires 3 type argument(s).ts(2314)
(alias) type PartialBlock<BSchema extends Record<string, BlockConfig>, I extends InlineContentSchema, S extends StyleSchema> = PartialBlocksWithoutChildren<BSchema, I, S>[keyof BSchema] & Partial<{
children: PartialBlock<BSchema, I, S>[];
}>
here's my Editor.tsx in which I've used blocknote editor. This component receives initialContent : string from page.tsx(attached below).
Activity
frostcraftventuresltd commentedon Jan 12, 2024
I've just been doing something like below for now until there's an update.
The functionality still works fine just needed to get the error to no throw for me to publish it out to vercel.
Still wrapping my head around this project, hopefully can help contribute in the future as I'm going to heavily use this for other projects too.
zcf0508 commentedon Jan 19, 2024
I find a way to resolve this problem,
ccec336(#524)What's important is that
editorneed inferblockSpecstype correctlyhelloWorldBlockneed declaration the type of block, likeYousefED commentedon Jan 22, 2024
For people facing this issue, most of this should be fixable removing the type annotation on the variable declaration. E.g. remove
: Block[]in the original example.When declaring Blocks, you can use
as constto help the TS compiler. For example, seeBlockNote/packages/core/src/api/testUtil/cases/customBlocks.ts
Line 96 in ed772f1
Background: BlockNote is designed to be as type-safe as possible, whilst being extensible. So in BlockNote, you can define your custom schema / types for blocks / inlinecontent / styles, and this will be reflected in the Type System. This is done using generics.
Whilst this is really powerful (you get proper code completion and error checking), sometimes it can be a bit cumbersome. The above tips should help!
In the meantime, I'll also look into the suggestions by @zcf0508 and other ways to make this a bit more easier!
aressss1 commentedon Jan 26, 2024
hi there, I'm facing a similar issue in PartialBlock.
here's the issue
here's my
Editor.tsxin which I've used blocknote editor. This component receivesinitialContent : stringfrompage.tsx(attached below).here's my page.tsx
I'll be grateful if someone helps me with this.
YousefED commentedon Mar 5, 2024
Hi all! This should be greatly improved with the new version. Lmk if you still run into issues!