diff --git a/source/parser.hera b/source/parser.hera index a88def10..9b09aec9 100644 --- a/source/parser.hera +++ b/source/parser.hera @@ -8304,7 +8304,7 @@ TypeBullet return list TypeWithPostfix - TypeConditional:t ( SameLineOrIndentedFurther TypeIfClause )?:postfix -> + TypeConditional:t ( _? TypeIfClause )?:postfix -> if (!postfix) return t return prepend(postfix[0], expressionizeTypeIf([ ...postfix[1], $1, undefined ])) diff --git a/test/types/function.civet b/test/types/function.civet index 15c33fb4..dcababd4 100644 --- a/test/types/function.civet +++ b/test/types/function.civet @@ -414,6 +414,26 @@ describe "[TS] function", -> } """ + // #1590 + testCase """ + not postfix if + --- + function fn(i: number): string + if i < 10 + "a" + else + "b" + --- + function fn(i: number): string { + if (i < 10) { + return "a" + } + else { + return "b" + } + } + """ + describe "application", -> testCase """ type arguments diff --git a/test/types/type-declaration.civet b/test/types/type-declaration.civet index f9f88b8c..cf40a8ce 100644 --- a/test/types/type-declaration.civet +++ b/test/types/type-declaration.civet @@ -653,14 +653,13 @@ describe "[TS] type declaration", -> type Example1 = (Dog extends Animal?never: number) """ - testCase """ + throws """ indented postfix if --- type Example1 = number if Dog extends Animal --- - type Example1 = - (Dog extends Animal? number:never) + ParseError """ testCase """