refactor: Relocate a type definition.

This commit is contained in:
Daniel J. Geiger 2023-09-08 13:12:50 -05:00
parent 1f9847ed98
commit fd9a172da9
2 changed files with 3 additions and 4 deletions

View File

@ -1,4 +1,3 @@
import { Subtype } from "../subtypes";
import { Point } from "../types"; import { Point } from "../types";
import { import {
FONT_FAMILY, FONT_FAMILY,
@ -66,7 +65,7 @@ type _ExcalidrawElementBase = Readonly<{
updated: number; updated: number;
link: string | null; link: string | null;
locked: boolean; locked: boolean;
subtype?: Subtype; subtype?: string;
customData?: Record<string, any>; customData?: Record<string, any>;
}>; }>;

View File

@ -51,13 +51,13 @@ export type SubtypeRecord = Readonly<{
}>; }>;
// Subtype Names // Subtype Names
export type Subtype = string; export type Subtype = Required<ExcalidrawElement>["subtype"];
export const getSubtypeNames = (): readonly Subtype[] => { export const getSubtypeNames = (): readonly Subtype[] => {
return subtypeNames; return subtypeNames;
}; };
export const isValidSubtype = (s: any, t: any): s is Subtype => export const isValidSubtype = (s: any, t: any): s is Subtype =>
parentTypeMap.find( parentTypeMap.find(
(val) => val.subtype === (s as string) && val.parentType === (t as string), (val) => (val.subtype as any) === s && (val.parentType as any) === t,
) !== undefined; ) !== undefined;
const isSubtypeName = (s: any): s is Subtype => subtypeNames.includes(s); const isSubtypeName = (s: any): s is Subtype => subtypeNames.includes(s);