Skip to content

fix(types): chain commands return ChainableCommandObject, not boolean (SD-2334)#2773

Merged
caio-pizzol merged 2 commits intomainfrom
caio/sd-2334-bug-chainable-command-typing-treats-chain-methods-as
Apr 10, 2026
Merged

fix(types): chain commands return ChainableCommandObject, not boolean (SD-2334)#2773
caio-pizzol merged 2 commits intomainfrom
caio/sd-2334-bug-chainable-command-typing-treats-chain-methods-as

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol commented Apr 10, 2026

PR #2565 (SD-2261) replaced the handwritten index.d.ts with auto-generated types from ChainedCommands.ts, fixing the ChainableCommandObject | boolean return type union that IT-344 and IT-780 reported. However, the replacement type still used KnownChainedCommands (empty for npm consumers — module augmentation doesn't survive the package boundary) and a Record<string, ...> index signature fallback, which left two problems:

  1. noPropertyAccessFromIndexSignature incompatibility — consumers with this TS strict flag can't use dot access on chain methods (chain.setTextSelection(...) errors with "must be accessed with bracket notation")
  2. No parameter type safety — all chain method params fall to unknown[] since KnownChainedCommands is empty

This PR applies the same fix already used for EditorCommands: compose AllChainedCommands from direct imports of each command interface, transformed via Chainified<T> to return ChainableCommandObject. Same treatment for CanObject.

  • Chain methods now have proper parameter types matching EditorCommands
  • No Record<string, ...> index signature — works with all TS strict flags
  • run() is unambiguously () => boolean
  • can().chain() returns ChainableCommandObject, not an overloaded intersection
  • Consumer-typecheck regression tests for IT-344 and IT-780 scenarios

Resolves SD-2334, IT-344, IT-780

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5617cd149f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/super-editor/src/editors/v1/core/types/ChainedCommands.ts Outdated
Comment thread packages/super-editor/src/editors/v1/core/types/ChainedCommands.ts Outdated
… (SD-2334)

ChainableCommandObject used KnownChainedCommands (empty for npm consumers
since module augmentation doesn't survive the package boundary) plus a
Record<string, ...> index signature that conflicted with run: () => boolean.
This caused TypeScript to infer intermediate chain methods could return
boolean, breaking chains like chain().setTextSelection(...).setMark(...).run().

Apply the same fix used for EditorCommands: compose AllChainedCommands from
direct imports of each command interface, transformed via Chainified<T> to
return ChainableCommandObject. Remove the Record<string, ...> fallback.
Same treatment for CanObject to prevent can().chain() type conflicts.
…upport

Address review feedback:
- Extract shared AllCommandSignatures base type used by EditorCommands,
  ChainableCommandObject, and CanObject (eliminates triple-maintained
  10-interface intersection)
- Add AugmentedChainedCommands/AugmentedCanCommands so consumers who
  extend ExtensionCommandMap via module augmentation still get their
  custom commands on chain() and can()
@caio-pizzol caio-pizzol force-pushed the caio/sd-2334-bug-chainable-command-typing-treats-chain-methods-as branch from c2ebff1 to 2e5ff6d Compare April 10, 2026 18:46
@caio-pizzol caio-pizzol enabled auto-merge April 10, 2026 18:48
@caio-pizzol caio-pizzol added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit 8f55848 Apr 10, 2026
49 of 52 checks passed
@caio-pizzol caio-pizzol deleted the caio/sd-2334-bug-chainable-command-typing-treats-chain-methods-as branch April 10, 2026 18:54
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in @superdoc-dev/react v1.0.0-next.37

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in vscode-ext v1.1.0-next.83

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in template-builder v1.3.0-next.43

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in esign v2.2.0-next.41

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc v1.24.0-next.80

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc-cli v0.5.0-next.81

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc-sdk v1.3.0-next.82

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc-sdk v1.4.0

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc v1.25.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc-cli v0.6.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in vscode-ext v2.3.0-next.1

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in template-builder v1.5.0-next.1

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in esign v2.3.0-next.1

The release is available on GitHub release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant