W
Waspā€¢3mo 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ā€¢3mo 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
TomasOPā€¢3mo ago
i currently import like this: import { getCourseTopics, useQuery } from 'wasp/client/operations'; @kapa.ai
kapa.ai
kapa.aiā€¢3mo 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
TomasOPā€¢3mo ago
@kapa.ai
kapa.ai
kapa.aiā€¢3mo 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
TomasOPā€¢3mo ago
@kapa.ai
kapa.ai
kapa.aiā€¢3mo 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ā€¢3mo 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ā€¢3mo ago
I'd advise restarting your code editor as well šŸ™‚
Tomas
TomasOPā€¢3mo 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ā€¢3mo ago
Wohooo @Tomas, you just became a Waspeteer level 1!
miho
mihoā€¢3mo ago
Could you share some code with us? The implementation code on the server and the usage code on the client?
Tomas
TomasOPā€¢3mo 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ā€¢3mo 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
TomasOPā€¢3mo ago
shared the repo with you! please let me know if you solve the issue
miho
mihoā€¢3mo 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
TomasOPā€¢3mo ago
nice! thanks! ill try that worked! thanks šŸ˜„
martinsos
martinsosā€¢3mo 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