fix: resolve duplicate identifier in cc-graph-shapes
This commit is contained in:
parent
0150ca3c32
commit
6610abbd72
@ -35,7 +35,6 @@ import { CCTimetableLessonNodeShape, CCTimetableLessonNodeShapeUtil } from './CC
|
|||||||
import { CCPlannedLessonNodeShape, CCPlannedLessonNodeShapeUtil } from './CCPlannedLessonNodeShapeUtil'
|
import { CCPlannedLessonNodeShape, CCPlannedLessonNodeShapeUtil } from './CCPlannedLessonNodeShapeUtil'
|
||||||
import { CCDepartmentStructureNodeShape, CCDepartmentStructureNodeShapeUtil } from './CCDepartmentStructureNodeShapeUtil'
|
import { CCDepartmentStructureNodeShape, CCDepartmentStructureNodeShapeUtil } from './CCDepartmentStructureNodeShapeUtil'
|
||||||
import { CCUserTeacherTimetableNodeShape, CCUserTeacherTimetableNodeShapeUtil } from './CCUserTeacherTimetableNodeShapeUtil'
|
import { CCUserTeacherTimetableNodeShape, CCUserTeacherTimetableNodeShapeUtil } from './CCUserTeacherTimetableNodeShapeUtil'
|
||||||
import { CCTimetableLessonNodeShape, CCTimetableLessonNodeShapeUtil } from './CCTimetableLessonNodeShapeUtil'
|
|
||||||
|
|
||||||
// Create a const object with all node types
|
// Create a const object with all node types
|
||||||
export const NODE_SHAPE_TYPES = {
|
export const NODE_SHAPE_TYPES = {
|
||||||
@ -82,7 +81,7 @@ export const NODE_SHAPE_TYPES = {
|
|||||||
export type NodeShapeType = typeof NODE_SHAPE_TYPES[keyof typeof NODE_SHAPE_TYPES];
|
export type NodeShapeType = typeof NODE_SHAPE_TYPES[keyof typeof NODE_SHAPE_TYPES];
|
||||||
|
|
||||||
// Define AllNodeShapes as a union type of all shape types
|
// Define AllNodeShapes as a union type of all shape types
|
||||||
export type AllNodeShapes =
|
export type AllNodeShapes =
|
||||||
| CCUserNodeShape
|
| CCUserNodeShape
|
||||||
| CCTeacherNodeShape
|
| CCTeacherNodeShape
|
||||||
| CCStudentNodeShape
|
| CCStudentNodeShape
|
||||||
@ -118,8 +117,7 @@ export type AllNodeShapes =
|
|||||||
| CCTimetableLessonNodeShape
|
| CCTimetableLessonNodeShape
|
||||||
| CCPlannedLessonNodeShape
|
| CCPlannedLessonNodeShape
|
||||||
| CCDepartmentStructureNodeShape
|
| CCDepartmentStructureNodeShape
|
||||||
| CCUserTeacherTimetableNodeShape
|
| CCUserTeacherTimetableNodeShape;
|
||||||
| CCTimetableLessonNodeShape;
|
|
||||||
|
|
||||||
// Export all shape utils in an object for easy access
|
// Export all shape utils in an object for easy access
|
||||||
export const ShapeUtils = {
|
export const ShapeUtils = {
|
||||||
@ -159,17 +157,16 @@ export const ShapeUtils = {
|
|||||||
[CCPlannedLessonNodeShapeUtil.type]: CCPlannedLessonNodeShapeUtil,
|
[CCPlannedLessonNodeShapeUtil.type]: CCPlannedLessonNodeShapeUtil,
|
||||||
[CCDepartmentStructureNodeShapeUtil.type]: CCDepartmentStructureNodeShapeUtil,
|
[CCDepartmentStructureNodeShapeUtil.type]: CCDepartmentStructureNodeShapeUtil,
|
||||||
[CCUserTeacherTimetableNodeShapeUtil.type]: CCUserTeacherTimetableNodeShapeUtil,
|
[CCUserTeacherTimetableNodeShapeUtil.type]: CCUserTeacherTimetableNodeShapeUtil,
|
||||||
[CCTimetableLessonNodeShapeUtil.type]: CCTimetableLessonNodeShapeUtil,
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// Add a type guard to check if a shape is a valid node shape
|
// Add a type guard to check if a shape is a valid node shape
|
||||||
export const isValidNodeShape = (shape: TLShape): shape is AllNodeShapes => {
|
export const isValidNodeShape = (shape: TLShape): shape is AllNodeShapes => {
|
||||||
return shape &&
|
return shape &&
|
||||||
typeof shape.type === 'string' &&
|
typeof shape.type === 'string' &&
|
||||||
Object.values(NODE_SHAPE_TYPES).includes(shape.type as NodeShapeType);
|
Object.values(NODE_SHAPE_TYPES).includes(shape.type as NodeShapeType);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add a type guard to check if a type string is a valid node type
|
// Add a type guard to check if a type string is a valid node type
|
||||||
export const isValidNodeType = (type: string): type is NodeShapeType => {
|
export const isValidNodeType = (type: string): type is NodeShapeType => {
|
||||||
return Object.values(NODE_SHAPE_TYPES).includes(type as NodeShapeType);
|
return Object.values(NODE_SHAPE_TYPES).includes(type as NodeShapeType);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user