Skip to content

Commit

Permalink
Add elaborating comments and improve type for wasp file
Browse files Browse the repository at this point in the history
  • Loading branch information
sodic committed Dec 10, 2024
1 parent 6d03463 commit 9638e32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions waspc/src/Wasp/Analyzer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ analyze prismaSchemaAst =
>=> (wrapAnalyzerError TypeError . typeCheck stdTypes)
>=> (wrapAnalyzerError EvaluationError . evaluate stdTypes)

-- | When writing main.wasp.ts, TypeScript should know about all the available
-- entities.
-- Since Wasp's AST includes entity declarations, the easiest way to get a list
-- of all entities defined in the Prisma Schema is by:
-- 1. Creating an AST with (and only with) the declarations for the Prisma
-- schema Entities.
-- 2. Type-checking that AST and returning the result.
-- This gives us a list of entity declarations we can then forward to
-- TypeScript (which then validates the user config only uses existing
-- entities).
getEntityDecls :: Psl.Schema.Schema -> Either [AnalyzeError] [Decl]
getEntityDecls schema =
wrapAnalyzerError TypeError (typeCheck stdTypes astWithEntitiesOnly)
Expand Down
3 changes: 2 additions & 1 deletion waspc/src/Wasp/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import StrongPath.Types (File)
import Wasp.Analyzer.Parser.Ctx (Ctx, getCtxRgn)
import Wasp.Analyzer.Parser.SourcePosition (SourcePosition (..))
import Wasp.Analyzer.Parser.SourceRegion (SourceRegion (..))
import Wasp.Project.Common (WaspLangFile)
import Wasp.Util (indent, insertAt, leftPad)
import qualified Wasp.Util.Terminal as T

-- | Transforms compiler error (error with parse context) into an informative, pretty String that
-- can be printed directly into the terminal. It uses terminal features like escape codes
-- (colors, styling, ...).
showCompilerErrorForTerminal :: (Path' Abs (File f), String) -> (String, Ctx) -> String
showCompilerErrorForTerminal :: (Path' Abs (File WaspLangFile), String) -> (String, Ctx) -> String
showCompilerErrorForTerminal (waspFilePath, waspFileContent) (errMsg, errCtx) =
let srcRegion = getCtxRgn errCtx
in intercalate
Expand Down

0 comments on commit 9638e32

Please sign in to comment.