apify-client-js icon indicating copy to clipboard operation
apify-client-js copied to clipboard

Request type could be improved

Open metalwarrior665 opened this issue 3 years ago • 1 comments

  1. A lot of the properties are | undefined. Why? Is there a case where the queue would not have those properties? I think we would need 2 different types, one for request options which have mostly optional values but when you use request as a type you get from somewhere, all these will be populated by default values so the type should reflect that.
  2. handledAt should be string | null as null is a value for in progress

metalwarrior665 avatar Aug 05 '22 15:08 metalwarrior665

A lot of the properties are | undefined.

Can you list which ones? I can see loadedUrl, id, and headers, rest seems to be already mandatory. And I can already see why - the object represents a request, not necessarily processed - you don't know the loadedUrl or headers until you process it, I guess same applies for the id.

https://github.com/apify/crawlee/blob/master/packages/core/src/request.ts#L72

FYI we already have two types, one is the Request class itself, and one is the RequestOptions interface.

So we should maybe have a third interface for processed request, and use that when appropriate.

B4nan avatar Mar 20 '23 09:03 B4nan