Skip to content

Most explicit stronger typing - #8

Open
Rudi Chen (rudi-c) wants to merge 1 commit into
mainfrom
stronger-typing-3
Open

Most explicit stronger typing#8
Rudi Chen (rudi-c) wants to merge 1 commit into
mainfrom
stronger-typing-3

Conversation

@rudi-c

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread src/project.ts
| { type: "sketch", obj: Sketch, change: TypedObjectChange<FileFormat.Sketch>, origin: ChangeOrigin }
| { type: "extrusion", obj: Extrusion, change: TypedObjectChange<FileFormat.Extrusion>, origin: ChangeOrigin }
| { type: "group", obj: Group, change: TypedObjectChange<FileFormat.Group>, origin: ChangeOrigin }
| { type: "level", obj: Sketch, change: TypedObjectChange<FileFormat.Level>, origin: ChangeOrigin }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively

type ElementChangeCreator<T extends Element, F extends FileFormat.Element> =
  | { type: T["type"], obj: T, change: TypedObjectChange<F>, origin: ChangeOrigin }

type ElementListenerChange =
  | ElementChangeCreator<Level, FileFormat.Level>
  | ElementChangeCreator<Sketch, FileFormat.Sketch>
  ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant