Closed markedwards closed 3 months ago
Thanks, this should be fixed in v6.0.0
.
Confirmed this is fixed. One slightly odd thing is I have to wrap my object like so:
return {
...obj,
};
Otherwise I get Type 'Foo' is not assignable to type 'BaseOptions'. Index signature for type 'string' is missing in type 'Foo'
. Presumably because the object is just described by an interface and does not inherit from Record<string, unknown>
?
Otherwise it works great though. Thanks!
There seems to be a subtle problem with the typing of
RouteMiddleware
if the function is async, and it can return both aNextResponse
and some custom options.Example:
This raises
Type '{ foo: string; }' is not assignable to type 'void | NextResponse<unknown> | TypedNextResponseType<unknown, number, AnyContentTypeWithAutocompleteForMostCommonOnes>'. ts(2345)
. Also, thefoo
argument in the handler isunknown
.If the function is made sync (and the
await sleep()
line is removed, there's no type error. So it seems to be some unimplemented type condition in the async case.