25 lines
604 B
TypeScript
25 lines
604 B
TypeScript
/**
|
|
* Base interface for ViewData objects
|
|
*
|
|
* All ViewData must be JSON-serializable for SSR.
|
|
* This type ensures no class instances or functions are included.
|
|
*
|
|
* Uncle Bob says: "Data structures should not have behavior."
|
|
* ViewData is a dumb container for primitives and nested JSON only.
|
|
*/
|
|
export interface ViewData {
|
|
[key: string]: any;
|
|
}
|
|
/**
|
|
* Helper type to ensure a type is ViewData-compatible
|
|
*
|
|
* Usage:
|
|
* ```typescript
|
|
* type MyViewData = ViewData & {
|
|
* title: string;
|
|
* count: number;
|
|
* items: string[];
|
|
* };
|
|
* ```
|
|
*/
|
|
export type ViewDataOf<T extends ViewData> = T; |