Skip to content

declare Builders type for builders()#9

Merged
marijnh merged 2 commits intoProseMirror:masterfrom
MH4GF:fix-type-of-builders
Jul 22, 2022
Merged

declare Builders type for builders()#9
marijnh merged 2 commits intoProseMirror:masterfrom
MH4GF:fix-type-of-builders

Conversation

@MH4GF
Copy link
Contributor

@MH4GF MH4GF commented Jul 14, 2022

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: #10
I have also confirmed that the type is valid in the test code of a private project I am involved in.

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.

This change provides a type that uses the schema and name of the builders argument to return the appropriate object.
@MH4GF MH4GF marked this pull request as ready for review July 14, 2022 13:25
@marijnh
Copy link
Member

marijnh commented Jul 21, 2022

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
Copy link
Contributor Author

MH4GF commented Jul 22, 2022

fix to restore any casts. 2cdbc9b

@marijnh marijnh merged commit 49fe7b9 into ProseMirror:master Jul 22, 2022
@MH4GF MH4GF deleted the fix-type-of-builders branch July 18, 2023 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants