|
| 1 | +/** |
| 2 | + * Consumer typecheck: PresentationEditor lookup on `SuperDoc`. |
| 3 | + * |
| 4 | + * Locks the `getPresentationEditorForDocument` contract (parameters |
| 5 | + * and returns) against the emitted `.d.ts` with strict identity |
| 6 | + * equality. A future migration that narrows or widens the signature |
| 7 | + * will fail the obligation diff rather than slipping past CI. |
| 8 | + * |
| 9 | + * Both halves of the contract reference publicly exported types: |
| 10 | + * - parameter is `[documentId: string]` |
| 11 | + * - return is `PresentationEditor | null` (PresentationEditor is |
| 12 | + * re-exported from `@superdoc/super-editor` via the facade and is |
| 13 | + * classified as `legacy-root` - typed for backward compatibility, |
| 14 | + * not the recommended public path, but still part of the surface) |
| 15 | + * |
| 16 | + * Runtime behavior the typedef does not capture: the method returns |
| 17 | + * null on empty/non-string ids before walking the document store. |
| 18 | + * That's a runtime concern; the type signature does not (and should |
| 19 | + * not) encode it. |
| 20 | + * |
| 21 | + * Drained obligations (2): |
| 22 | + * - getPresentationEditorForDocument:parameters |
| 23 | + * - getPresentationEditorForDocument:returns |
| 24 | + */ |
| 25 | +import type { PresentationEditor, SuperDoc } from 'superdoc'; |
| 26 | + |
| 27 | +type Equal<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? true : false; |
| 28 | +type AssertEqual<A, B> = Equal<A, B> extends true ? true : never; |
| 29 | + |
| 30 | +declare const sd: SuperDoc; |
| 31 | + |
| 32 | +const _paramsOk: AssertEqual<Parameters<SuperDoc['getPresentationEditorForDocument']>, [documentId: string]> = true; |
| 33 | +const _returnOk: AssertEqual< |
| 34 | + ReturnType<SuperDoc['getPresentationEditorForDocument']>, |
| 35 | + PresentationEditor | null |
| 36 | +> = true; |
| 37 | + |
| 38 | +const _looked: PresentationEditor | null = sd.getPresentationEditorForDocument('doc-id-1'); |
| 39 | +void _looked; |
| 40 | + |
| 41 | +void [_paramsOk, _returnOk]; |
0 commit comments