fix parse type to always return Node #121

Merged
BrianHung merged 1 commit from parse-always-return-node into master 2024-05-16 10:10:08 +02:00
BrianHung commented 2024-05-16 10:06:36 +02:00 (Migrated from github.com)

The type for parse is currently

    parse(text: string, markdownEnv?: Object): Node | null;

because it uses Node.createAndFill(). But because content is always null, we can assume createAndFill() always returns a Node.

github.com/ProseMirror/prosemirror-model@b71f73f193/src/schema.ts (L157-L169)

The type for `parse` is currently ```ts parse(text: string, markdownEnv?: Object): Node | null; ``` because it uses `Node.createAndFill()`. But because `content` is always null, we can assume `createAndFill()` always returns a `Node`. https://github.com/ProseMirror/prosemirror-model/blob/b71f73f193b15ab1661451636352905b06a6fb0d/src/schema.ts#L157-L169
marijnh commented 2024-05-16 10:09:29 +02:00 (Migrated from github.com)

Oh, indeed, that optional return type was entirely unintentional. Thanks for spotting it.

Oh, indeed, that optional return type was entirely unintentional. Thanks for spotting it.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-markdown!121
No description provided.