-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontracts.parity.ts
More file actions
28 lines (24 loc) · 1.21 KB
/
Copy pathcontracts.parity.ts
File metadata and controls
28 lines (24 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type {
ErrorCode as ContractErrorCode,
TaskEventName as ContractEventName,
TaskPriority as ContractPriority,
TaskStatus as ContractStatus,
} from '@taskflow/contracts';
import type { ErrorCode } from './common/exceptions/error-codes';
import type { TaskEventName } from './events/task-events';
import type { TaskStatus } from './tasks/entities/task-status.enum';
import type { TaskPriority } from './tasks/entities/task.entity';
/**
* Compile-time contract conformance. This file emits nothing; it exists so the
* build FAILS if the backend's enums / codes / event names ever diverge from
* the shared API contract (`shared/contracts.d.ts`). It's the cheap insurance
* that keeps "single source of truth" honest without a runtime cost.
*/
type Assert<T extends true> = T;
type Equal<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;
// `${TaskStatus}` collapses the string enum to its value union for comparison.
type _StatusParity = Assert<Equal<`${TaskStatus}`, ContractStatus>>;
type _PriorityParity = Assert<Equal<TaskPriority, ContractPriority>>;
type _EventParity = Assert<Equal<TaskEventName, ContractEventName>>;
type _ErrorParity = Assert<Equal<`${ErrorCode}`, ContractErrorCode>>;
export {};