Explorar el Código

refactor: Relocate a type definition.

Daniel J. Geiger hace 1 año
padre
commit
fd9a172da9
Se han modificado 2 ficheros con 3 adiciones y 4 borrados
  1. 1 2
      src/element/types.ts
  2. 2 2
      src/subtypes.ts

+ 1 - 2
src/element/types.ts

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

+ 2 - 2
src/subtypes.ts

@@ -51,13 +51,13 @@ export type SubtypeRecord = Readonly<{
 }>;
 
 // Subtype Names
-export type Subtype = string;
+export type Subtype = Required<ExcalidrawElement>["subtype"];
 export const getSubtypeNames = (): readonly Subtype[] => {
   return subtypeNames;
 };
 export const isValidSubtype = (s: any, t: any): s is Subtype =>
   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;
 const isSubtypeName = (s: any): s is Subtype => subtypeNames.includes(s);