Description
openedon Dec 6, 2023
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 the get
method of res = await this.rest.get<WorkItemTrackingInterfaces.WorkItem>(url, options);
explictly says and types it as having a result
of null
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 is any
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, when this.rest.get
returns null
. In that case, the promise resolves as null
.
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()
returning null
when it isn't typed as returning such.