Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example doesn't work anymore #44

Closed
k3rne1pan1c opened this issue May 6, 2024 · 1 comment
Closed

Example doesn't work anymore #44

k3rne1pan1c opened this issue May 6, 2024 · 1 comment

Comments

@k3rne1pan1c
Copy link

Using the following dependencies:

 "dependencies": {
    "@hono-storage/core": "^0.0.9",
    "@hono-storage/node-disk": "^0.0.10",
    "@hono/node-server": "^1.11.1",
    "hono": "^4.3.2"
  },
  "devDependencies": {
    "@types/node": "^20.11.17",
    "tsx": "^4.7.1"
  }

index.ts

import { serve } from "@hono/node-server";
import { HonoDiskStorage } from "@hono-storage/node-disk";
import { Hono } from "hono";

const app = new Hono();
const storage = new HonoDiskStorage({
  dest: "./uploads",
  filename: (_, file) => `${file.originalname}-${Date.now()}.${file.extension}`,
});

app.post("/", storage.single("file"), (c) => c.text("OK"));

serve(app);

Error message over storage.single()

No overload matches this call.
  The last overload gave the following error.
    Argument of type 'MiddlewareHandler<{ Variables: { files: { file?: FieldValue | undefined; }; }; }>' is not assignable to parameter of type 'H<Env, "/", BlankInput, HandlerResponse<any>>'.
      Type 'MiddlewareHandler<{ Variables: { files: { file?: FieldValue | undefined; }; }; }>' is not assignable to type 'MiddlewareHandler<Env, "/", BlankInput>'.
        Types of parameters 'c' and 'c' are incompatible.
          Type 'Context<Env, "/", BlankInput>' is not assignable to type 'Context<{ Variables: { files: { file?: FieldValue | undefined; }; }; }, string, {}>'.
            Property '#private' in type 'Context' refers to a different member that cannot be accessed from within type 'Context'.ts(2769)
types.d.ts(154, 5): The last overload is declared here.

You got an idea, what's wrong?

@sor4chi
Copy link
Owner

sor4chi commented May 9, 2024

It seems that there is a type discrepancy when using Hono 4 series Hono because they have not updated the Hono version.
I’ll patch it the next version, Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants