Commit 427736a
authored
fix(types): auto-generate TS types by converting barrel to TypeScript (SD-2261) (#2565)
* fix(types): auto-generate TS types by converting barrel to TypeScript (SD-2261)
Convert super-editor barrel from index.js to index.ts with type re-exports,
replacing the hand-written index.d.ts with types derived from actual source
files. This ensures type declarations always match runtime behavior.
- Rename super-editor/src/index.js → index.ts, add type re-exports
- Delete hand-written index.d.ts (1140 lines of manually maintained types)
- Delete redundant Editor.d.ts sidecar (shadows Editor.ts)
- Add missing types: BoundingRect, BinaryData, UnsupportedContentItem
- Update vite.config.js and package.json entry points
- Expand superdoc barrel with missing runtime exports and JSDoc type re-exports
* fix(types): correct OpenOptions import path and superdoc vite alias
- Move OpenOptions re-export from EditorConfig.js to Editor.js (where
it's actually defined)
- Update superdoc vite.config.js aliases from index.js to index.ts
* fix(types): add missing type re-exports for backward compat
Add CoreCommandMap, ExtensionCommandMap, and LayoutUpdatePayload to
type re-exports — these were in the old hand-written index.d.ts and
need to remain available for consumers.
* fix(types): fix shim generation for export type re-exports and common subpaths
- Update ensure-types.cjs regex to match `export type { ... } from` in
addition to `import { ... } from`, so re-exported names like Fragment
are included in workspace package shims
- Allow @superdoc/common subpath imports (e.g. BasicUpload.vue) to be
shimmed instead of skipped
- Update public-api test to reference renamed index.ts
* fix(types): include Vue shim in tsconfig and add missing sidecar export
- Add vue-shim.d.ts to super-editor tsconfig include so tsc can resolve
.vue imports from the renamed index.ts barrel
- Add createOrUpdateTrackedChangeComment to comments-plugin.d.ts sidecar
* test(types): add TS compatibility matrix and fix .ts extension paths
Add typecheck-matrix.mjs that tests consumer types across 9 scenarios:
bundler/node16/nodenext module resolution, strict/loose mode,
headless Node.js usage, and superdoc/super-editor sub-exports.
Fix ensure-types.cjs to convert .ts extensions to .js in generated
.d.ts import paths — vite-plugin-dts preserves .ts from the source
entry point, but consumers need .js for TypeScript resolution.
* fix(types): type CommentsPluginKey and remove dead branch in matrix
- Type CommentsPluginKey as PluginKey instead of any
- Remove duplicated srcErrors === 0 branch in typecheck matrix
* fix(types): delegate runtime exports to v1 barrel, fix type re-export paths
The index.ts was duplicating all imports from editors/v1/index.js with
wrong relative paths (missing editors/v1/ prefix). Use export * from
the v1 barrel for runtime exports and only keep type re-exports with
corrected paths.
* fix(types): add event and parts type re-exports for consumer handlers
Export all types consumers need to type EditorEventMap handlers:
- EditorEvents: Comment, CommentsPayload, CommentLocationsPayload,
FontsResolvedPayload, PaginationPayload, ListDefinitionsPayload,
ProtectionChangeSource, EditorEventMap
- Parts: PartChangedEvent, PartId, PartSectionId
- Document API: DocumentProtectionState
* fix(types): export EditorOptions, User, ProseMirrorJSON and all config types
Add all public-facing types consumers need for constructor options,
method params, and configuration: EditorOptions, User, ProseMirrorJSON,
ExportFormat, EditorLifecycleState, ViewOptions, CommentConfig,
CollaborationProvider, LinkPopoverResolver, PermissionParams, etc.1 parent e1dc6d5 commit 427736a
19 files changed
Lines changed: 638 additions & 1242 deletions
File tree
- packages
- super-editor
- src
- editors/v1
- core
- presentation-editor
- types
- extensions/comment
- superdoc
- scripts
- src
- tests/consumer-typecheck
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
This file was deleted.
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
391 | 400 | | |
392 | 401 | | |
393 | 402 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
88 | 102 | | |
89 | 103 | | |
90 | 104 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments