Skip to content

Commit

Permalink
fix(ts): fix query array literal
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Nov 15, 2022
1 parent 77399ac commit 6e1890b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ singleExpression
// for: `onHotUpdateSuccess?.();`
| singleExpression '?'? '!'? '.' '#'? '(' identifierName? ')' # MemberDotExpression
// onChange?.(userName || password || null)
| singleExpression '?'? '!'? '.' '#'? '(' singleExpression? ')' # MemberDotExpression
| singleExpression '?'? '!'? '.' '#'? '('? singleExpression? ')'? # MemberDotExpression
// samples: `error?.response?.data?.message ?? error.message;`
| singleExpression '??' singleExpression # NullCoalesceExpression
| singleExpression '!' # PropCheckExpression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,15 @@ import {EMPTY, Observable, of} from 'rxjs';
"""
TypeScriptAnalyser().analysis(code, "index.tsx")
}

@Test
fun query_array_literal() {
val code = """
export class DemoComponent implements OnInit, ControlValueAccessor {
confirm(): void {
return this.form.value?.id?.[0] || null
}
}"""
TypeScriptAnalyser().analysis(code, "index.tsx")
}
}

0 comments on commit 6e1890b

Please sign in to comment.