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

fix: Add Type validation for get/set method #901

Merged
merged 1 commit into from
Jun 19, 2023
Merged

Conversation

kamiazya
Copy link
Member

@kamiazya kamiazya commented Jun 19, 2023

What was a problem

The type check of the value corresponding to the key of the set method was not performed.

graph.attributes.edge.set(attribute.color, 's'); // it should be error, but it is not error

How this PR fixes the problem

This PR fixes the problem by adding a type check to the set method.

export interface Attributes<T extends AttributeKey> {
  ...
  get<K extends T>(key: K): Attribute<K> | undefined;
  set<K extends T>(key: K, value: Attribute<K>): void;
  ...
}

Additional Context

close #900

@kamiazya kamiazya self-assigned this Jun 19, 2023
@kamiazya kamiazya merged commit bfe23b7 into main Jun 19, 2023
6 checks passed
@kamiazya kamiazya deleted the fix-model-set-api branch June 19, 2023 12:27
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.

The type validation of the set method value is disabled
1 participant