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(interaction-output): adjust storing behavior and return type of value method #1211

Merged
merged 2 commits into from
Jan 11, 2024

Conversation

JKRhb
Copy link
Member

@JKRhb JKRhb commented Jan 8, 2024

While dealing with the InteractionOutput class, I noticed that a small bug (due to the != null check) was introduced that prevents already parsedValues of type null from being properly returned. This PR solves the issue by replacing the check with !== undefined, so that null values are not being ignored anymore.

Copy link

codecov bot commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5dc47c4) 77.60% compared to head (fcfe687) 77.61%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1211   +/-   ##
=======================================
  Coverage   77.60%   77.61%           
=======================================
  Files          83       83           
  Lines       17311    17313    +2     
  Branches     1747     1747           
=======================================
+ Hits        13435    13437    +2     
  Misses       3840     3840           
  Partials       36       36           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JKRhb
Copy link
Member Author

JKRhb commented Jan 8, 2024

A general related question: Shouldn't the return type of this method rather be Promise<DataSchemaValue> instead of a generic Promise<T>?

@relu91
Copy link
Member

relu91 commented Jan 8, 2024

A general related question: Shouldn't the return type of this method rather be Promise<DataSchemaValue> instead of a generic Promise<T>?

The correct way should be:

value<T extends DataSchemaValue>(): Promise<T>

This should allow the user to do funny stuff like:

 const b = await output.value<string>() // b inferred to be string without casting

Note: this is something experimental that only works for node-wot users, is not coming from the scripting API

@JKRhb JKRhb changed the title fix(interaction-output): allow stored value to be null fix(interaction-output): adjust storing behavior and return type of value method Jan 9, 2024
@JKRhb
Copy link
Member Author

JKRhb commented Jan 9, 2024

Thank you @relu91! I incorporated your feedback in fcfe687 :)

Copy link
Member

@relu91 relu91 left a comment

Choose a reason for hiding this comment

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

Thanks! Good to go!

@danielpeintner danielpeintner merged commit e8e0cd2 into eclipse-thingweb:master Jan 11, 2024
10 of 11 checks passed
@JKRhb JKRhb deleted the interaction-output-fix branch January 12, 2024 13:06
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.

3 participants