wasp icon indicating copy to clipboard operation
wasp copied to clipboard

Defining operations in a particular order breaks compilation

Open sodic opened this issue 1 year ago • 2 comments

The details are described here: https://github.com/wasp-lang/wasp/issues/969.

In short, we count on the Wasp compiler to tolerate missing operation definitions.

We tell our users to:

  1. First declare it inside the Wasp file (the compiler tolerates the missing implementations and generates the types).
  2. Then define its implementation in TypeScript (and use the generated types).

When users do this out of order (as I often do), wasp compile breaks and stays broken even after all the code is completely valid.

This happens because the compiler didn't get the chance to generate the types before the user mentioned them in the implementation file. Essentially, the compiler needs to run at least once while the declaration points to a non-existing implementation.

This is only fixable by removing types from the implementation file.

A user hit it here: https://discord.com/channels/686873244791210014/1288139584676565022/1288139584676565022

sodic avatar Sep 24 '24 19:09 sodic

Oh man! Yeah this sucks, and nice job on defining this so well, I think we had multiple people hitting this. Any idea on how best we can fix this?

Martinsos avatar Sep 24 '24 20:09 Martinsos

Seems it's not as bad as I thought.

Essentially, the compiler needs to run at least once while the declaration points to a non-existing implementation.

If this were true, then running wasp start on finished projects (like TodoAppTs) would never work. And they do. So it doesn't suck that hard (but still sucks).

sodic avatar Oct 16 '24 11:10 sodic