diff --git a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 index f4d38755..234059ed 100644 --- a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 +++ b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 @@ -211,7 +211,7 @@ typeAnnotation ; callSignature - : typeParameters? '(' parameterList? ','? ')' typeAnnotation? + : typeParameters? '(' parameterList? ','? ')' typeAnnotation? ';'? ; parameterList @@ -390,7 +390,7 @@ statementList ; abstractDeclaration - : Abstract (Identifier callSignature | variableStatement) eos + : Abstract (Identifier '?'? callSignature | variableStatement) eos ; importStatement diff --git a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptRegressionTest.kt b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptRegressionTest.kt index 6081baa4..dd64de67 100644 --- a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptRegressionTest.kt +++ b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptRegressionTest.kt @@ -108,6 +108,15 @@ export class DemoComponent implements OnInit, ControlValueAccessor { TypeScriptAnalyser().analysis(code2, "index.tsx") } + @Test + fun type_in_interface() { + val code = """export abstract class ReactiveOptionProviderService { + abstract create?(name: string): Observable; +}""" + + TypeScriptAnalyser().analysis(code, "index.tsx") + } + @Test fun numeric_separators() { val code = """if (+value > 1_000_000_000) {