-
Notifications
You must be signed in to change notification settings - Fork 479
Open
Labels
typesRelated to @cloudflare/workers-typesRelated to @cloudflare/workers-types
Description
Since version 4.20241004.0, there is a Request type mismatch when using exactOptionalPropertyTypes.
Example 1
export default {
async fetch(request) {
const newRequest = new Request("newUrl", request);
// ^^^^^^^
return fetch(newRequest);
},
} satisfies ExportedHandler;Argument of type 'Request<unknown, IncomingRequestCfProperties<unknown>>' is not assignable to parameter of type 'RequestInit<CfProperties<unknown>>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Types of property 'cf' are incompatible.
Type 'IncomingRequestCfProperties<unknown> | undefined' is not assignable to type 'CfProperties<unknown>'.
Type 'undefined' is not assignable to type 'CfProperties<unknown>'.
Example 2
export default {
async fetch(request) {
const newRequest = new Request(request);
return fetch("newUrl", newRequest);
// ^^^^^^^^^^
},
} satisfies ExportedHandler;No overload matches this call.
Overload 1 of 2, '(input: RequestInfo, init?: RequestInit<RequestInitCfProperties> | undefined): Promise<Response>', gave the following error.
Argument of type 'Request<unknown, CfProperties<unknown>>' is not assignable to parameter of type 'RequestInit<RequestInitCfProperties>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Types of property 'cf' are incompatible.
Type 'CfProperties<unknown> | undefined' is not assignable to type 'RequestInitCfProperties'.
Type 'undefined' is not assignable to type 'RequestInitCfProperties'.
Overload 2 of 2, '(input: RequestInfo | URL, init?: RequestInit<CfProperties<unknown>> | undefined): Promise<Response>', gave the following error.
Argument of type 'Request<unknown, CfProperties<unknown>>' is not assignable to parameter of type 'RequestInit<CfProperties<unknown>>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Types of property 'cf' are incompatible.
Type 'CfProperties<unknown> | undefined' is not assignable to type 'CfProperties<unknown>'.
Type 'undefined' is not assignable to type 'CfProperties<unknown>'.
r3dpoint, ArtskydJ, KrisBraun, jczstudios, rkusa and 4 more
Metadata
Metadata
Assignees
Labels
typesRelated to @cloudflare/workers-typesRelated to @cloudflare/workers-types
Type
Projects
Status
Backlog