mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 21:50:00 -05:00
fix: serve handler error with 0 arguments (#23652)
Fixes https://github.com/denoland/deno/issues/23651 Co-authored-by: Satya Rohith <me@satyarohith.com>
This commit is contained in:
parent
a13c4531fd
commit
eec8800513
2 changed files with 7 additions and 2 deletions
|
@ -793,9 +793,9 @@ internals.serveHttpOnConnection = serveHttpOnConnection;
|
|||
|
||||
function registerDeclarativeServer(exports) {
|
||||
if (ObjectHasOwn(exports, "fetch")) {
|
||||
if (typeof exports.fetch !== "function" || exports.fetch.length !== 1) {
|
||||
if (typeof exports.fetch !== "function") {
|
||||
throw new TypeError(
|
||||
"Invalid type for fetch: must be a function with a single parameter",
|
||||
"Invalid type for fetch: must be a function with a single or no parameter",
|
||||
);
|
||||
}
|
||||
return ({ servePort, serveHost }) => {
|
||||
|
|
5
tests/testdata/serve/no_args.ts
vendored
Normal file
5
tests/testdata/serve/no_args.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
export default {
|
||||
fetch() {
|
||||
return new Response("deno serve with no args in fetch() works!");
|
||||
},
|
||||
};
|
Loading…
Add table
Reference in a new issue