Skip to content

Commit

Permalink
feat(ts): add readonly issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Nov 15, 2022
1 parent 72ad42a commit b548af9
Show file tree
Hide file tree
Showing 2 changed files with 14 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 @@ -686,7 +686,7 @@ formalParameterList
;

formalParameterArg
: decorator? accessibilityModifier? identifierOrKeyWord '?'? typeAnnotation? ('=' singleExpression)? // ECMAScript 6: Initialization
: decorator? accessibilityModifier? ReadOnly? identifierOrKeyWord '?'? typeAnnotation? ('=' singleExpression)? // ECMAScript 6: Initialization
| lastFormalParameterArg
// ([key, value]: [string, string[]])
| arrayLiteral (':' formalParameterList)? // ECMAScript 6: Parameter Context Matching
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,17 @@ export class DemoComponent implements OnInit, ControlValueAccessor {
}"""
TypeScriptAnalyser().analysis(code, "index.tsx")
}

@Test
fun readonly_property() {
val code = """class DataSource extends Data<Item> {
readonly pageSize = 5;
constructor(public readonly type: TaskEnum,) {
super();
}
}"""

TypeScriptAnalyser().analysis(code, "index.tsx")
}
}

0 comments on commit b548af9

Please sign in to comment.