Skip to content

fix(core/platform): fixed types for sdkVersion and osVersion #10269

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

Merged
merged 2 commits into from
Apr 17, 2023

Conversation

guillemc23
Copy link
Contributor

@guillemc23 guillemc23 commented Apr 16, 2023

PR Checklist

What is the current behavior?

Currently, both Device.sdkVersion and Device.osVersion return a number in Android. The typings state that this should be a string so expressions like if (Device.sdkVersion >= 23) {...} are not possible.

What is the new behavior?

I added number | string to the IDevice interface declaration so these expressions are allowed without the need to add @ts-ignore. I also updated the JSDoc to reflect this change.

These two return a number in Android (can't test iOS). Adding this fix would make expressions such as `Device.sdkVersion >= 23` possible without the need to add `@ts-ignore` before
Updated JSDoc to reflect Android behavior
@nx-cloud
Copy link

nx-cloud bot commented Apr 16, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 4cfc742. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@cla-bot cla-bot bot added the cla: yes label Apr 16, 2023
Copy link
Contributor

@NathanWalker NathanWalker left a comment

Choose a reason for hiding this comment

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

Excellent thank you @guillemc23

@NathanWalker NathanWalker merged commit f8edee4 into NativeScript:main Apr 17, 2023
NathanWalker added a commit that referenced this pull request Apr 17, 2023
NathanWalker added a commit that referenced this pull request Apr 17, 2023
#10270)

Revert "fix(core): sdkVersion and osVersion type adjustments (#10269)"

This reverts commit f8edee4.
@NathanWalker
Copy link
Contributor

@guillemc23 I reverted for the patch release as it does cause a breaking change. The platform types returned do in fact return strings however I think for 8.6 (when a breaking change like this could be introduced) it would likely be better to have it return just a number and let core do the parsing - it's likely debatable given the string does often include codenames on release details from the platform that may be desirable to know/get. Possible we may want to introduce a new number only getter to use in future.

@guillemc23
Copy link
Contributor Author

Understood! That's a great idea too. Thank you Nathan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants