-
-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type Error: Generic type 'Block' requires 3 type arguments #497
Comments
I've just been doing something like below for now until there's an update. const [blocks, setBlocks] = useState<Block<any, any, any>[]>([]);
const insertHelloWorld = (editor: BlockNoteEditor) => {
// Block that the text cursor is currently in.
const currentBlock: Block<any, any, any> = editor.getTextCursorPosition().block;
// New block we want to insert.
const helloWorldBlock: 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([helloWorldBlock as any], 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. |
I find a way to resolve this problem, What's important is that
|
For people facing this issue, most of this should be fixable removing the type annotation on the variable declaration. E.g. remove When declaring Blocks, you can use
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
here's my
here's my page.tsx
I'll be grateful if someone helps me with this. |
Hi all! This should be greatly improved with the new version. Lmk if you still run into issues! |
Describe the bug
Facing error of typescript regarding Block[ ]
Misc
The text was updated successfully, but these errors were encountered: