Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: fix untyped model when using ElementView/LinkView #2585

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

michaelspiss
Copy link
Contributor

@michaelspiss michaelspiss commented Mar 22, 2024

Description

Instead of passing a generic Element/Link type to CellViewGeneric this provides an optional generic to pass the model type. It would be used like the following:

interface CustomElementAttributes extends dia.Element.Attributes {
  custom_attribute: string,
}

class CustomElement extends dia.Element<CustomElementAttributes> {
  // ...
}

class CustomElementView extends dia.ElementView<CustomElement> {
  // ...
}

Default behaviour is the current behaviour. The change is fully backwards compatible.

Motivation and Context

  • this.model.get(...) is checked against attributes of the model
    • return value is typed instead of any
    • language server knows about possible keys
  • No longer throws errors ("... implicitely has any type") when used with typescript
    • Removes manual overhead of hard coding types back in after using get()

Copy link
Contributor

@kumilingus kumilingus left a comment

Choose a reason for hiding this comment

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

Just this one undocumented method needs to be updated.

Good work!

@kumilingus kumilingus changed the title Fixes untyped model when using ElementView/LinkView types: fix untyped model when using ElementView/LinkView Mar 24, 2024
@kumilingus kumilingus merged commit 9f0241e into clientIO:master Mar 25, 2024
3 checks passed
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.

2 participants