Incorrect Return Type of WorkItemTrackingApi.getWorkItem()
, when runtime can return null
#574
Labels
WorkItemTrackingApi.getWorkItem()
, when runtime can return null
#574
Concerning
WorkItemTrackingApi.getWorkItem()
,azure-devops-node-api/api/WorkItemTrackingApi.ts
Line 3791 in fa534ae
Promise<WorkItemTrackingInterfaces.WorkItem>
is the type of the resolved promise, but the description of theget
method ofres = await this.rest.get<WorkItemTrackingInterfaces.WorkItem>(url, options);
explictly says and types it as having aresult
ofnull
if the response code is 404.https://github.com/microsoft/typed-rest-client/blob/ddca2d90a7ed441e2e49d770bb5fe5456b410c5d/lib/RestClient.ts#L53
Now
this.formatResponse
's return type isany
but logically what it returns should be handled such that it ends up matching the return type of the resolved promise when it resolves, right? That's not happening here, whenthis.rest.get
returnsnull
. In that case, the promise resolves asnull
.Is this loophole the responsibility of the consumers of this library, or should it be handled here? I ask because I'm running into errors using a consuming library (https://github.com/rfennell/AzurePipelines/tree/main/Extensions/XplatGenerateReleaseNotes) due to
getWorkItem()
returningnull
when it isn't typed as returning such.The text was updated successfully, but these errors were encountered: