Repository navigation
Fix PropsMerge type so setNodes merge can return scalars - #6137
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 0a92d70 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
dylans
requested changes
Oct 7, 2026
| ) | ||
| ` | ||
|
|
||
| const compileSnippet = () => { |
Collaborator
There was a problem hiding this comment.
- since Fix and Type Tests (and some type errors I found along the way) #6003,
packages/slate/testis part oftsc --build, soyarn lint:typescriptalready type-checks test files in CI - a plain typed call in a test file covers this, no compiler harness needed
- e.g.
Transforms.setNodes(editor, {}, { merge: (prop: unknown, node: unknown) => node })fails on main and passes with this change - this harness also type-checks all of slate's source every time mocha loads
- rebase onto main (19 commits behind, no conflicts), then swap this file for the typed call
Contributor
Author
There was a problem hiding this comment.
Rebased onto main and swapped the harness for a typed setNodes call. yarn lint:typescript fails with TS2322 on the old PropsMerge and passes with this change.
`merge` is applied to each property value and its result is stored in `Record<string, unknown>`, so requiring an `object` return rejected valid scalar merges (TS2322). Widen the return type to `unknown` to match the parameters. Refs ianstormtaylor#5490
cpruijsen
force-pushed
the
fix/issue-5490-610416c0
branch
from
October 8, 2026 10:05
187795d to
0a92d70
Compare
dylans
approved these changes
Oct 8, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
description
Allow
PropsMergecallbacks to return scalar property values.packages/slate/src/interfaces/editor.tschanges the return type fromobjecttounknown.setNodescallsmergefor each property and stores the result inRecord<string, unknown>.issue
Refs #5490.
Property-specific callback parameter types remain open, so the issue's explicitly annotated examples still fail strict function checks.
example
For a custom text node with a
keyproperty:Before the change, TypeScript rejects this callback because
unknownis not assignable toobject. The new declaration accepts the callback.context
The shared declaration covers
Transforms.setNodesandeditor.setNodesand keeps the currentunknownparameter contract.Property-specific parameter and return inference must account for absent existing properties and multiple supplied keys.
packages/slate/test/props-merge.tscompiles snippets against Slate source with the existing TypeScript dependency because the Mocha Babel loader removes TypeScript annotations.checks
yarn test --watchman=false --runInBand: 1,423 Mocha tests and 97 Jest tests.yarn lint.Tests use Node
22.17.0, which matches CI.