denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.46k stars 643 forks source link

TS2345 [ERROR] in `start()` at `main.ts` #1590

Closed afifurrohman-id closed 1 year ago

afifurrohman-id commented 1 year ago

When run

deno check main.ts

i have following error

Argument of type '{ routes: { './routes/_404.tsx': typeof $0; './routes/_500.tsx': typeof $1; './routes/_app.tsx': typeof $2; './routes/_middleware.ts': typeof $3; './routes/auth/index.ts': typeof $4; './routes/auth/login.ts': typeof $5; ... 5 more ...; './routes/index.tsx': typeof $11; }; islands: { ...; }; baseUrl: string; }' is not assignable to parameter of type 'Manifest'.
  Types of property 'routes' are incompatible.
    Type '{ './routes/_404.tsx': typeof $0; './routes/_500.tsx': typeof $1; './routes/_app.tsx': typeof $2; './routes/_middleware.ts': typeof $3; './routes/auth/index.ts': typeof $4; './routes/auth/login.ts': typeof $5; './routes/auth/logout.ts': typeof $6; ... 4 more ...; './routes/index.tsx': typeof $11; }' is not assignable to type 'Record<string, RouteModule | MiddlewareModule<any> | AppModule | ErrorPageModule | UnknownPageModule>'.
      Property ''./routes/dashboard/[id].tsx'' is incompatible with index signature.
        Type 'typeof import("file:///D:/Documents/dev/coding/projects/finish/notes-app/routes/dashboard/[id]")' is not assignable to type 'RouteModule | MiddlewareModule<any> | AppModule | 

FIx by add as unknown as Manifest

await start(manifest as unknown as Manifest , {
  plugins: [twindPlugin(twindConfig)]})
deer commented 1 year ago

Can you please provide details on your project? This is difficult to reproduce otherwise.

afifurrohman-id commented 1 year ago

Ah idk what is the problem, because not impact into my app when run. Just error lint, here this app that have issue

deer commented 1 year ago

@marvinhagemeister, I think we can close this. The manifest looks like this:

const manifest = {
  routes: {
    './routes/_404.tsx': $0,
    './routes/_500.tsx': $1,
    './routes/_app.tsx': $2,
    './routes/_middleware.ts': $3,
    './routes/auth/index.ts': $4,
    './routes/auth/login.ts': $5,
    './routes/auth/logout.ts': $6,
    './routes/dashboard/[id].tsx': $7,
    './routes/dashboard/_middleware.ts': $8,
    './routes/dashboard/index.tsx': $9,
    './routes/dashboard/profile.tsx': $10,
    './routes/index.tsx': $11,
  },
  islands: {
    './islands/Utils.tsx': $$0,
    './islands/note/Edit.tsx': $$1,
    './islands/note/View.tsx': $$2,
    './islands/user/Profile.tsx': $$3,
  },
  baseUrl: import.meta.url,
}

The following three routes use async server components:

    './routes/dashboard/[id].tsx': $7,
    './routes/dashboard/index.tsx': $9,
    './routes/dashboard/profile.tsx': $10,

The error can get fixed by changing RouteContext to RouteContext<PageProps> or by using the canary version.

This is resolved by #1536, so waiting for 1.4 is also a viable option.

Additionally there's a problem with your islands/Utils.tsx file. You're trying to export a function useEventSource which isn't an island, and therefore doesn't belong in this folder.

marvinhagemeister commented 1 year ago

Thanks for the investigation!

Closing because it's resolved with #1536 .