tsconfig update for v0.13.1
Hey Guys, in your migration guide you state, that one should add two new lines to the
tsconfig.json
file.
When I do so, my typings for Server-Operations don't work anymore.
This was working just fine before and still is with v0.13.1 but not anymore after adding this tsconfig.
Then the type import cannot be resolved and thus params
is unknown
and returnn
is any
.
Any idea on what i am doing wrong here?
If i add only "target": "esnext"
to the config it already fails. And i can not add moduleResolution
on its own.
@sodic You suggested this change in an other thread, so maybe you are the right person to ask? (sorry to bother you)23 Replies
Hi @Gwaggli. 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 don't contain specific information about the issue you're encountering with the
tsconfig.json
update for v0.13.1 and the Server-Operations typings.
However, it's worth noting that there have been discussions about managing tsconfig.json
files in Wasp, and the idea of Wasp checking if they are there, generating them if they're not, and fixing them if something is wrong has been suggested (source (https://github.com/wasp-lang/wasp/issues/939)).
There have also been changes in Wasp 0.12.0 that deprecated some issues related to tsconfig.json
files (source (https://github.com/wasp-lang/wasp/issues/1057), source (https://github.com/wasp-lang/wasp/issues/1415)).
I recommend checking the official Wasp documentation or reaching out to the Wasp community for more specific guidance on your issue.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Gwaggli, 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?Hmm, good question @Gwaggli. We might have messed something up.
Can you give me full info for reproducing this:
- Screenshot of the error
- The Wasp file and the operation file where the error occurs (if not private). Or, ideally, your entire project in a zip or a github repo 😄
- Also, are you getting the error in your editor or during the build?
@sodic You suggested this change in an other thread, so maybe you are the right person to ask? (sorry to bother you)And no problem at all! I'm here to help 😄
Thanks for getting back to me!
I just reproduced this with a clean wasp project:
And then a simple action:
With the standard configuration the import resolve fails and thus the typings can not be inferred.
Error:
Cannot find module 'wasp/server/operations' or its corresponding type declarations.ts(2307)
Excellent! Thank you very much, I'll get right on it
Unrelated tip: You should capitalize your type names. Nothing to do with the error, but it's a standard in TS (
FunctionType
instead of functionType
, etc.)
I can't reproduce this. I've started your project and everything works normally
Just a secondAh yeah, normally i do 😄 just forgot in this example 😄
Am i right that i need to use TS version
5.1.0
or is there a way to upgrade this? (could that be the source of the issue?)No, TS 5.1.0 should be fine (and there's no easy way for you to update it yet)
Did you try to restart the TS language server?
Here's a snippet from a doc page that we lost (but plan to bring back)
Your editor may sometimes report type and import errors even while wasp start
is running. This happens when the TypeScript Language Server gets out of sync with the current code. If you're using VS Code, you can manually restart the language server by opening the command palette and selecting "TypeScript: Restart TS Server."
Try it in the example repro project while wasp start is running. Also, check the terminal - are there any errors there?Hmm weird, I did that before already but maybe exactly at the wrong time 😄
If it works in your small example repro app, try it in the real thing
It's still possible you're getting a different error there
But follow up:
If you add this line:
const test: MyAction<Args, Result> = async (args, context) => {};
Do you get the type inference on the parameters?
I lose them once I switch the config to esnext
. But get them, when i remove the target
option.I now see, that the import resolving was never the issue (this was TS Server dependent) and also works in my real app. But the type inference in the methods parameters does not work in either.
Yes, I can definitely reproduce this. Congratulations, you've found a bug (and a big one too)!
Wohooo @sodic, you just became a Waspeteer level 30!
I'll dig into it and keep you posted
Thanks for hte help
Haha thank you! Let me know if I can be of any Help 🙂
Ok, I believe I've found the issue. I'll do my best to get the fix out today.
Damn you're a machine! 😄
In the meantime, here's a quick fix you can use:
In
.wasp/out/sdk/wasp/package.json
, add the following line to the exports
object:
Haha, thanks for the kind words, but this is mostly becuase I happen to know the creator of this bug very wellYour fix did the job for me 👍
Hahaha yeah fair, but still. Nice job and greatly appreciate the help and insane speed 😄
Great to hear!
Keep in mind that Wasp might regenerate that file at one point, which will remove the fix you added. If you want a command that you can quickly run from the terminal to do this edit for you, here it is.
If you don't have
jq
installed, I highly recommend you get it. It's an awesome tool: https://github.com/jqlang/jq
I'll let you know as soon as the release with the fix is outGreat, thanks! I am not developing atm so I dont need this workaround but thank you anyways! didn't know about
jq
. Thanks for the help. Much appreciated 🙂Hey @Gwaggli, the new version of Wasp that fixes this error is finally out (sorry it took until today 😅)
As always, you can install it with curl:
There are no braking changes so all your old project will work automatically 🙂
Great news, thank you so much!