Skip to content

Commit 177596b

Browse files
authored
Merge pull request #3493 from superdoc-dev/caio-pizzol/SD-typecheck-coverage-drain-5
test(typecheck): drain 2 PresentationEditor-lookup obligations (SD-673)
2 parents 0ade67d + 875aada commit 177596b

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

tests/consumer-typecheck/public-method-coverage-debt-snapshot.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"export:returns",
1010
"exportEditorsToDOCX:parameters",
1111
"exportEditorsToDOCX:returns",
12-
"getPresentationEditorForDocument:parameters",
13-
"getPresentationEditorForDocument:returns",
1412
"lockSuperdoc:parameters",
1513
"lockSuperdoc:returns",
1614
"removeCommentsList:returns",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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

Comments
 (0)