Commit 8f55848
authored
fix(types): chain commands return ChainableCommandObject, not boolean (SD-2334) (#2773)
* fix(types): chain commands return ChainableCommandObject, not boolean (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.
* refactor(types): extract AllCommandSignatures, restore augmentation support
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()1 parent 9d03f01 commit 8f55848
File tree
2 files changed
+64
-29
lines changed- packages/super-editor/src/editors/v1/core/types
- tests/consumer-typecheck/src
2 files changed
+64
-29
lines changedLines changed: 55 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
52 | 55 | | |
53 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
54 | 66 | | |
55 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
56 | 82 | | |
57 | 83 | | |
58 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
59 | 95 | | |
60 | 96 | | |
61 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
62 | 101 | | |
63 | 102 | | |
64 | 103 | | |
65 | | - | |
66 | | - | |
| 104 | + | |
| 105 | + | |
67 | 106 | | |
68 | 107 | | |
69 | 108 | | |
70 | 109 | | |
71 | 110 | | |
72 | 111 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | 112 | | |
78 | 113 | | |
79 | 114 | | |
80 | 115 | | |
81 | 116 | | |
82 | 117 | | |
83 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
84 | 122 | | |
85 | | - | |
86 | | - | |
| 123 | + | |
| 124 | + | |
87 | 125 | | |
88 | 126 | | |
89 | 127 | | |
| |||
100 | 138 | | |
101 | 139 | | |
102 | 140 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
106 | 144 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 145 | + | |
120 | 146 | | |
121 | 147 | | |
122 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
273 | 282 | | |
274 | 283 | | |
275 | 284 | | |
| |||
0 commit comments