refactor: improve types around dataState and libraryData (#3427)

This commit is contained in:
David Luzar
2021-04-10 19:17:49 +02:00
committed by GitHub
parent c19c8ecd27
commit a7cbe68ae8
10 changed files with 84 additions and 55 deletions

View File

@ -1,26 +1,29 @@
import { ExcalidrawElement } from "../element/types";
import { AppState, LibraryItems } from "../types";
import type { cleanAppStateForExport } from "../appState";
export interface DataState {
type?: string;
version?: string;
source?: string;
export interface ExportedDataState {
type: string;
version: number;
source: string;
elements: readonly ExcalidrawElement[];
appState: Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
appState: ReturnType<typeof cleanAppStateForExport>;
}
export interface ImportedDataState {
type?: string;
version?: string;
version?: number;
source?: string;
elements?: DataState["elements"] | null;
appState?: Partial<DataState["appState"]> | null;
elements?: readonly ExcalidrawElement[] | null;
appState?: Readonly<Partial<AppState>> | null;
scrollToContent?: boolean;
}
export interface LibraryData {
type?: string;
version?: number;
source?: string;
library?: LibraryItems;
export interface ExportedLibraryData {
type: string;
version: number;
source: string;
library: LibraryItems;
}
export interface ImportedLibraryData extends Partial<ExportedLibraryData> {}