declare Builders type for builders() #9

Merged
MH4GF merged 2 commits from fix-type-of-builders into master 2022-07-22 09:02:29 +02:00
MH4GF commented 2022-07-14 15:13:41 +02:00 (Migrated from github.com)

Description

This change provides a type that uses the schema and name of the builders argument to return the appropriate object.

Motivation

Until now, the only explicit return type of builder has been schema.
Therefore, to use the builder in a TypeScript project, it had to be cast to any.

How Has This Been Tested?

I wanted to modify test-mark.ts, but this file could not reflect the changes because it is imported from npm, not the source code.
I confirmed that any here can be removed, along with this one: https://github.com/ProseMirror/prosemirror-test-builder/pull/10
I have also confirmed that the type is valid in the test code of a private project I am involved in.

# Description This change provides a type that uses the schema and name of the builders argument to return the appropriate object. # Motivation Until now, the only explicit return type of builder has been schema. Therefore, to use the builder in a TypeScript project, it had to be cast to any. # How Has This Been Tested? I wanted to modify test-mark.ts, but this file could not reflect the changes because it is imported from npm, not the source code. I confirmed that [any here](https://github.com/ProseMirror/prosemirror-test-builder/blob/88b9ce4a83b2bcd00bd71bbe1c174b19fe3ac2bf/test/test-marks.ts?plain=1#L28) can be removed, along with this one: https://github.com/ProseMirror/prosemirror-test-builder/pull/10 I have also confirmed that the type is valid in the test code of a private project I am involved in.
marijnh commented 2022-07-21 16:16:10 +02:00 (Migrated from github.com)

This code doesn't typecheck — you removed the any casts, but the type of result is such that they are in fact still needed there.

This code doesn't typecheck — you removed the `any` casts, but the type of `result` is such that they are in fact still needed there.
MH4GF commented 2022-07-22 04:51:31 +02:00 (Migrated from github.com)
fix to restore any casts. https://github.com/ProseMirror/prosemirror-test-builder/pull/9/commits/2cdbc9bea62f8cd21c7845c95ca72358944562a0
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-test-builder!9
No description provided.