W
Wasp-langβ€’3w ago
Tomas

Full stack type safety wasp 0.13 to 0.14

I am having trouble with some errors that appeared when i migrated from wasp 0.13 to 0.14. I seem to have lost all the types that came for example with the useQuery function and therefore i get type errors all over my code. I followed every step in the migration guide but nothing seems to solve these issues.
19 Replies
kapa.ai
kapa.aiβ€’3w ago
Hi @Tomas. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain specific information about migrating from Wasp 0.13 to 0.14 and the potential issues that might arise with full-stack type safety. However, I can tell you that Wasp does provide full-stack type safety. For instance, when using the useQuery hook, Wasp automatically infers the type from the Query's backend implementation, ensuring that the types on the client always match the types on the server (source (https://wasp-lang.dev/docs/data-model/operations/queries#the-usequery-hook)). If you're experiencing issues with missing types, it might be due to an incorrect import. For example, useQuery should be imported from @wasp/queries (source (https://discord.com/channels/686873244791210014/1214694033683914762)). If you're still having trouble, I recommend checking the Wasp documentation (https://wasp-lang.dev/docs) or reaching out to the Wasp community for further assistance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Tomas, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Tomas
Tomasβ€’3w ago
i currently import like this: import { getCourseTopics, useQuery } from 'wasp/client/operations'; @kapa.ai
kapa.ai
kapa.aiβ€’3w ago
Let me check the knowledge base for you. One moment! :books: Sorry @Tomas, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Tomas
Tomasβ€’3w ago
@kapa.ai
kapa.ai
kapa.aiβ€’3w ago
Let me check the knowledge base for you. One moment! :books: Sorry @Tomas, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Tomas
Tomasβ€’3w ago
@kapa.ai
kapa.ai
kapa.aiβ€’3w ago
Let me check the knowledge base for you. One moment! :books: Sorry @Tomas, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
martinsos
martinsosβ€’3w ago
@Tomas that is looking good, those imports! You said you lost all the types -> meaning that imports are reported by the IDE to be incorrect? Any other informatino you can share -> at which point exactly did this start happening during migrating? That is quite unusual as we didn't do any big changeson that front in 0.14 copmared to 0.13. Have you tried doing wasp clean, does that maybe help? What if you try creating a new project with Wasp, do you get errors there also?
miho
mihoβ€’3w ago
I'd advise restarting your code editor as well πŸ™‚
Tomas
Tomasβ€’3w ago
my problem specifically is with the useQuery for example where the data before came with the types. Now when i have data.topics (in my case) for example it says that data is of type unknown (before migrating it knew the type that came from the query) Its not an IDE problem given that i noticed this error when trying to deploy and then when i went into the files i noticed my linter cought them as well (deploying with fly.io)
MEE6
MEE6β€’3w ago
Wohooo @Tomas, you just became a Waspeteer level 1!
miho
mihoβ€’3w ago
Could you share some code with us? The implementation code on the server and the usage code on the client?
Tomas
Tomasβ€’3w ago
there is the frontend file that is calling the query file the error is this : Property 'topics' does not exist on type '{}' as i said before, i didnt change anything else other than what the migration steps described and these issues started happening
miho
mihoβ€’3w ago
I'm looking at the code πŸ‘€ Meanwhile, could we try one of our default "did you try turning it off and on" fixes: 1. Run wasp clean 2. Then wasp db migrate-dev 3. And then wasp start 4. Also restart the code editor. Looking at your code - it looks to me like it should work 🫠 Would you mind sharing your whole project with me in the DMs (either a zip or invite me to your GH repository)? It usually helps a lot to be able to run the project and debug.
Tomas
Tomasβ€’3w ago
shared the repo with you! please let me know if you solve the issue
miho
mihoβ€’3w ago
@Tomas this seems to be a problem with our language server (thing that helps VS Code report code issues) Your folder structure is quite nice - reexporting your queries from index.ts:
.
β”œβ”€β”€ server
β”‚Β Β  β”œβ”€β”€ queries
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ challenge.ts
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ course.ts
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ index.ts // πŸ‘€ look here
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ question.ts
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ stats.ts
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ topic.ts
β”‚Β Β  β”‚Β Β  └── user.ts
.
β”œβ”€β”€ server
β”‚Β Β  β”œβ”€β”€ queries
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ challenge.ts
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ course.ts
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ index.ts // πŸ‘€ look here
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ question.ts
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ stats.ts
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ topic.ts
β”‚Β Β  β”‚Β Β  └── user.ts
then declaring the queries like this this:
query getCourseTopics {
fn: import { getCourseTopics } from "@src/server/queries",
entities: [Topic, Subtopic, SubtopicElement]
}
query getCourseTopics {
fn: import { getCourseTopics } from "@src/server/queries",
entities: [Topic, Subtopic, SubtopicElement]
}
where you import from a "folder" ("@src/server/queries") and you expect implicitly for Node.js to find the index.ts file. Our extension should have told you - hey this is not possible but it didn't. We are using a specific module resolution strategy called NodeNext which only allows explicit imports of the index.ts file and won't work for folder imports like the above. So, if you change your Wasp file code to:
query getCourseTopics {
fn: import { getCourseTopics } from "@src/server/queries/index",
entities: [Topic, Subtopic, SubtopicElement]
}
query getCourseTopics {
fn: import { getCourseTopics } from "@src/server/queries/index",
entities: [Topic, Subtopic, SubtopicElement]
}
Notice that I added the index bit - the types will work again. cc: @sodic @martinsos I'll let you triage this one (I think we have an open issue maybe for this type of stuff).
Tomas
Tomasβ€’3w ago
nice! thanks! ill try that worked! thanks πŸ˜„
martinsos
martinsosβ€’3w ago
GitHub
Ext import in Wasp file doesn't support importing from a folder via...
Related discord convo: https://discord.com/channels/686873244791210014/1291549944859066421/1293109502584815627 . Our extension should have told you - hey this is not possible but it didn't. We ...
Want results from more Discord servers?
Add your server