You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With strictNullChecks set to true, selecting 'device_tag' field results in type error.
This is not specific to only 'device_tag' field. Any field that has a type ReverseNavigationResource<T> fails.
Type '"device_tag"' is not assignable to type '"id" | "actor" | "created_at" | "modified_at" | "custom_latitude" | "custom_longitude" | "device_name" | "download_progress" | "ip_address" | "public_address" | "mac_address" | ... 43 more ... | "should_be_managed_by__supervisor_release"'. ts(2322)
With strictNullChecks set to false, there's no error.
Steps to Reproduce the Problem
git clone https://github.com/barribarrier/strictNullChecks-balena-sdk-issue.git
cd strictNullChecks-balena-sdk-issue
npm install
npm run build
Hi,
Thanks for raising this and for the POC repo.
I think this is actually the intended behavior, since ReverseNavigationResource properties in $select have no effect and they normally are supposed to be provided in $expands.
The query that you provided above will actually throw a 500 error when running against balenaCloud, because of having the device_environment_variableReverseNavigationResource in the $select.
The part that this becomes a bit weird though is that having the device_tag in the $select happens to be fine by the backend as long as it is also part of an $expand.
The SDK's typings are trying to be slightly stricter on this and block ReverseNavigationResource properties in $selects completely (rather than checking whether they also show up in the $expand) to protect the user in the common case.
The typings are explicitly handling this case here:
Oh, I didn't know that. I just assumed specifying them in $select was mandatory.
Thanks.
thgreasi
changed the title
Type error when "strictNullChecks: true"
Type error when adding an already expanded ReverseNavigationResource in the $select list
Jun 1, 2023
Expected Behavior
No type error
Actual Behavior
With
strictNullChecks
set totrue
, selecting 'device_tag' field results in type error.This is not specific to only 'device_tag' field. Any field that has a type
ReverseNavigationResource<T>
fails.Type '"device_tag"' is not assignable to type '"id" | "actor" | "created_at" | "modified_at" | "custom_latitude" | "custom_longitude" | "device_name" | "download_progress" | "ip_address" | "public_address" | "mac_address" | ... 43 more ... | "should_be_managed_by__supervisor_release"'. ts(2322)
With
strictNullChecks
set tofalse
, there's no error.Steps to Reproduce the Problem
git clone https://github.com/barribarrier/strictNullChecks-balena-sdk-issue.git cd strictNullChecks-balena-sdk-issue npm install npm run build
OR
Specifications
References
The text was updated successfully, but these errors were encountered: