Skip to content

Commit

Permalink
Support asserts syntax without predicate
Browse files Browse the repository at this point in the history
FIX: Allow TypeScript  syntax, where the condition is just a variable.

Issue #41
  • Loading branch information
marijnh committed Dec 3, 2024
1 parent 002c166 commit eb95618
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/javascript.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ patternAssign {

TypeAnnotation { ":" type }

TypePredicate { ":" tskw<"asserts">? (VariableName | kw<"this">) !predicate tskw<"is"> type }
TypePredicate {
":" (
tskw<"asserts">? (VariableName | kw<"this">) (tskw<"is"> type)? |
(VariableName | kw<"this">) !predicate tskw<"is"> type
)
}

patternAssignTyped {
pattern Optional? TypeAnnotation? ("=" expressionNoComma)?
Expand Down

0 comments on commit eb95618

Please sign in to comment.