Skip to content

Commit

Permalink
Update types.ts
Browse files Browse the repository at this point in the history
extend Node type for typescript
  • Loading branch information
better-think authored Sep 27, 2023
1 parent 662eb51 commit 2928709
Showing 1 changed file with 59 additions and 66 deletions.
125 changes: 59 additions & 66 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,87 +1,80 @@
export type Mutable<T> = {
-readonly [P in keyof T]: T[P];
};

export const enum Gender {
male = 'male',
female = 'female',
}

Check failure on line 1 in src/types.ts

View workflow job for this annotation

GitHub Actions / build

Declaration or statement expected.

export const enum RelType {
blood = 'blood',
married = 'married',
divorced = 'divorced',
adopted = 'adopted',
half = 'half',
blood = 'blood',
married = 'married',
divorced = 'divorced',
adopted = 'adopted',
half = 'half',
}

export const enum FamilyType {
root = 'root',
child = 'child',
parent = 'parent',
root = 'root',
child = 'child',
parent = 'parent',
}

export type Family = {
readonly id: number;
readonly type: FamilyType;
readonly main: boolean;
/** Parent family ID */
pid?: number;
/** Child family ID */
cid?: number;
/** Family's left coordinate */
X: number;
/** Family's top coordinate */
Y: number;
parents: readonly Unit[];
children: readonly Unit[];
readonly id: number;
readonly type: FamilyType;
readonly main: boolean;
/** Parent family ID */
pid?: number;
/** Child family ID */
cid?: number;
/** Family's left coordinate */
X: number;
/** Family's top coordinate */
Y: number;
parents: readonly Unit[];
children: readonly Unit[];
}

export type Unit = {
/** Family ID */
readonly fid: number;
/** Is child unit */
readonly child: boolean;
readonly nodes: readonly Node[];
pos: number;
/** Family ID */
readonly fid: number;
/** Is child unit */
readonly child: boolean;
readonly nodes: readonly Node[];
pos: number;
}

export type Size = Readonly<{
width: number;
height: number;
width: number;
height: number;
}>

export type Relation = Readonly<{
id: string;
type: RelType;
id: string;
type: RelType;
}>

export type Node = Readonly<{
id: string;
gender: Gender;
parents: readonly Relation[];
children: readonly Relation[];
siblings: readonly Relation[];
spouses: readonly Relation[];
placeholder?: boolean;
export type Node = T & Readonly<{

Check failure on line 52 in src/types.ts

View workflow job for this annotation

GitHub Actions / build

Exported type alias 'Node' has or is using private name 'T'.
id: string;
gender: Gender;

Check failure on line 54 in src/types.ts

View workflow job for this annotation

GitHub Actions / build

Exported type alias 'Node' has or is using private name 'Gender'.
parents: readonly Relation[];
children: readonly Relation[];
siblings: readonly Relation[];
spouses: readonly Relation[];
placeholder?: boolean;
}>

export type ExtNode = Node & Readonly<{
top: number;
left: number;
hasSubTree: boolean;
top: number;
left: number;
hasSubTree: boolean;
}>

export type Connector = readonly [x1: number, y1: number, x2: number, y2: number];

export type RelData = Readonly<{
canvas: Size;
families: readonly Family[];
nodes: readonly ExtNode[];
connectors: readonly Connector[];
canvas: Size;
families: readonly Family[];
nodes: readonly ExtNode[];
connectors: readonly Connector[];
}>

export type Options = Readonly<{
rootId: string;
placeholders?: boolean;
rootId: string;
placeholders?: boolean;
}>

0 comments on commit 2928709

Please sign in to comment.