Better error messages for implicit contract with generated code #211
Replies: 3 comments
-
I created a starting point for an
This can be used as a standalone rule that gives users feedback in their editor if they use VS Code with Eventually, we can wire it in to run from |
Beta Was this translation helpful? Give feedback.
-
I created a project board to track ideas and tasks: https://github.com/dillonkearns/elm-pages/projects/4. |
Beta Was this translation helpful? Give feedback.
-
The wiring is now complete as of NPM package 2.1.9. |
Beta Was this translation helpful? Give feedback.
-
The generated code in
elm-pages
has an implicit contract. It is implicit unlike the contracts we're used to in Elm because the user's code is imported and used by generated code, so error messages will point to generated files as the source of the error which is misleading because the fix is to change something in user-maintained code.Examples:
RouteParams
in a Page Module must have the expected record fields (all of type String), as used in theelm-pages add <My.Page.Route>
templateModel
andMsg
(with no type variables)Since Elm and
elm-pages
strive to have friendly error messages that give you clear actionable feedback, it would be nice to improve this.Considerations
elm-pages build
command eitherI think that we could achieve this functionality in a performant and maintainable way if we used
elm-review
to run these checks, but only ran it after runningelm make
and seeing that there is a compiler error pointing to a generated module. Ideally, users should never see an error message pointing to generated code since this isn't actionable for them. And we can avoid paying a performance penalty for all cases besides the ones we're interested in by checking that condition.Beta Was this translation helpful? Give feedback.
All reactions