-
-
Notifications
You must be signed in to change notification settings - Fork 255
Only allow declares inside declare module #73
Conversation
@@ -0,0 +1,3 @@ | |||
{ | |||
"throws": "Unexpected token (2:2)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to have a better error message here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like: "Only declare statements are allowed inside declare module {}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah something like that. Could even give an example (we haven't really done that)
I've been liking elm's errors/messages http://elm-lang.org/blog/compilers-as-assistants
Current coverage is 96.91% (diff: 100%)@@ master #73 diff @@
==========================================
Files 19 19
Lines 2922 2922
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
Hits 2832 2832
Misses 90 90
Partials 0 0
|
I changed the error message to be a little bit nicer. |
pp.unexpected = function (pos) { | ||
this.raise(pos != null ? pos : this.state.start, "Unexpected token"); | ||
pp.unexpected = function (pos, message = "Unexpected token") { | ||
this.raise(pos != null ? pos : this.state.start, message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I like being able to change the error message. Unexpected token is not fun to see (my example is function a() { await b; }
) without async in front of function
k 👍 , @jeffmo |
👍 this looks correct to me. Everything inside of a |
This is the followup of #71
This now checks for the term
declare
being used insidedeclare module
. Previously everything was allowed instead of declare. https://astexplorer.net/#/Y6hVjJkQ2m