diff --git a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 index 21b46ab9..7d04c226 100644 --- a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 +++ b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 @@ -170,7 +170,7 @@ typeMember | indexSignature | methodSignature ('=>' type_)? | enumSignature - | '[' typeReference In (Keyof | Typeof)* typeReference ']' typeAnnotation + | '[' typeReference In (Keyof | Typeof)* typeReference ']' '?'? typeAnnotation ; arrayType 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 c4cfe86c..c17a3cd0 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 @@ -102,5 +102,8 @@ export class DemoComponent implements OnInit, ControlValueAccessor { fun type_definition() { val code = """export type Exact = { [K in keyof T]: T[K] };""" TypeScriptAnalyser().analysis(code, "index.tsx") + + val code2 = """export type MakeOptional = Omit & { [SubKey in K]?: Maybe };""" + TypeScriptAnalyser().analysis(code2, "index.tsx") } }