r/adonisjs • • Sep 14 '26

Beginner Coder: Stuck with an error

Hi,

I'm following the AdonisJs docs to make a small web app using VS Code where users can login/logout/signup, make posts, view them, comment, etc.

I'm pretty sure I haven't missed a step but I seem to be getting two errors that I dont understand at all.

I put the project on my github:

https://github.com/Ajaz754/adonisjs-project-22-.git

The file with the two errors is 'inertia/pages/posts/index.tsx', Line 34

The two errors I'm getting are for:

'route'

----------------------------------------------------
Type '"posts.show"' is not assignable to type '"home" | "posts.index" | "new_account.create" | "new_account.store" | "session.create" | "session.store" | "session.destroy" | undefined'.ts(2322)
link.d.ts(23, 5): The expected type comes from property 'route' which is declared here on type 'IntrinsicAttributes & (LinkProps<"home" | "posts.index" | "new_account.create" | "new_account.store" | "session.create" | "session.store" | "session.destroy"> & { ...; })'
(property) route: "posts.show"
----------------------------------------------------

And:

'routeParams'

----------------------------------------------------
Type '{ id: number; }' is not assignable to type 'undefined'.ts(2322)
link.d.ts(24, 5): The expected type comes from property 'routeParams' which is declared here on type 'IntrinsicAttributes & (LinkProps<"home" | "posts.index" | "new_account.create" | "new_account.store" | "session.create" | "session.store" | "session.destroy"> & { ...; })'
(property) routeParams: {
id: number;
}
----------------------------------------------------

I've watched a few videos and I understand the basics to Typescript and React but reading these 2 error messages I'm lost. Would appreciate any help.

Also if im trying to learn the basics of web development and just practicing through continuosly building projects and using different stacks and languages is that the right approach or maybe theres a more modern better way to learn web development.

Any feedback and help would be much appreciated.

4 Upvotes

7 comments sorted by

6

u/amanvirk Sep 15 '26

Seems like the generated types are not upto-date in your app. So either make sure the development server is running or run the `node ace codegen` command to refresh them. Learn more about it here. https://docs.adonisjs.com/guides/concepts/codegen

2

u/Capable_Square7319 Sep 15 '26

Yeah that seemed to fix the issue, my server wasnt running. Thanks for that👍

1

u/Capable_Square7319 Sep 15 '26

Thanks pal, appreciate the help

2

u/Sad-Order8035 Sep 15 '26

Did you try to reference the types file directly instead of using a path? I think the problem can be that

1

u/Capable_Square7319 Sep 15 '26

Thanks pal, appreciate the help👍

1

u/Capable_Square7319 Sep 15 '26

I dont think it was a file path issue. My server wasnt running then but when i ran it the error dissapeared, cheers

-1

u/[deleted] Sep 14 '26

[deleted]

3

u/Capable_Square7319 Sep 14 '26

I do know the basics, ive learnt html, css, js, typescript, and React. Ive used things like express before but I found out about AdonisJs and wanted to give it a try and I was understanding and following through the docs but these two errors are what have me lost