W
Wasp•2mo ago
trapkinglazar

TypeScript issues:

wasp version 0.16.2 on Ubuntu having type safety issues that are crashing my wasp, i can't get started on developing I replaced the demo-app with something nearly identical, yet it throws cannot find type on this: Cannot find module 'wasp/client/operations' or its corresponding type declarations.ts(2307) // src/savant-start/SavantStartPage.tsx import React, { useState, useEffect } from 'react' import { CgSpinner } from 'react-icons/cg' // Official Wasp approach for queries/actions in client code: import { useQuery } from 'wasp/client/operations' import { getAllAnkiCards, uploadAnkiFile } from './operations' ... rest of code my operations file also has trouble importing HttpError which is part of wasp? Cannot find module 'wasp/server' or its corresponding type declarations. // src/savant-start/operations.ts import OpenAI from 'openai'; import { HttpError } from 'wasp/server'; import { z } from 'zod'; ...rest of code i tried migrating db. i dont understand how the type definitions are created or why they aren't being picked up. i did not modify tsconfig
3 Replies
kapa.ai
kapa.ai•2mo ago
Hi @trapkinglazar. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, it seems you're encountering TypeScript issues related to missing type declarations in your Wasp project. Let's address these issues step by step: 1. First, it's important to note that you're using Wasp version 0.16.2, which is relatively recent. However, some of the issues you're facing are similar to those reported in older versions. 2. The errors you're seeing, such as "Cannot find module 'wasp/client/operations'" and "Cannot find module 'wasp/server'", are typically related to the Wasp compiler not generating the necessary TypeScript declarations or the IDE not recognizing them. 3. Here are some steps you can try to resolve these issues: a. Run wasp clean followed by wasp start. This will delete the .wasp folder and node_modules, then reinstall and recompile everything. This solution was suggested in a Discord support thread for a similar issue. b. Make sure you've run wasp start at least once before trying to develop. As mentioned in another Discord thread, the Wasp compiler needs to compile the SDK for you to have all the wasp/* packages. c. Check if you've accidentally modified any files in the .wasp directory. This directory is generated by Wasp and should not be modified manually. d. Ensure that your IDE is recognizing the generated TypeScript files. Sometimes, restarting your IDE or reopening the project can help. 4. Regarding the HttpError import issue, make sure you're importing it correctly. The correct import should be:
import { HttpError } from 'wasp/server'

import { HttpError } from 'wasp/server'

If this import is still not recognized, it might be due to the same issue of Wasp not generating the necessary type declarations. 5. It's worth noting that Wasp is aware of some issues related to TypeScript support and IDE integration. There's an ongoing discussion about improving this, as mentioned in a GitHub issue about IDE integration. If these steps don't resolve your issue, you might want to try creating a new Wasp project from scratch and gradually adding your custom code to see at which point the type errors occur. This could help isolate the problem. If the problem persists, it would be helpful to share more details about your project structure and any modifications you've made to the default Wasp setup. You might also want to report this as an issue on the Wasp GitHub repository, as it could be a bug in the current version. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @trapkinglazar, 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?
trapkinglazar
trapkinglazarOP•2mo ago
seems like i am following the docs/recommenedations exactly. tried wasp clean/start and restarting my TS server and IDE i saw the other guy upgraded node to 22, i did the same thing, cleaned and restarted everything and it seems to work now seems like a lot of typescript issues, the terminal doesn't align with what the IDE marks as wrong, requires lots of restarting wasp. im out
Filip
Filip•2mo ago
Fair enough 😄 Thanks for trying Wasp out anyway. Come back when we reach 1.0, we'll be more mature at that stage

Did you find this page helpful?