From e064477ad3eef343d84d81e89217bd4ef10251f4 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Tue, 15 Nov 2022 20:24:00 +0800 Subject: [PATCH] fix: fix type error issue --- chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 | 1 + .../chapi/ast/typescriptast/TypeScriptRegressionTest.kt | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 index 565015c0..21b46ab9 100644 --- a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 +++ b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 @@ -87,6 +87,7 @@ type_ | constructorType | typeGeneric | '|'? propertyName ('|' (propertyName))* + | Unknown ; unionOrIntersectionOrPrimaryType 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 83d26008..c4cfe86c 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 @@ -97,4 +97,10 @@ export class DemoComponent implements OnInit, ControlValueAccessor { TypeScriptAnalyser().analysis(code, "index.tsx") } + + @Test + fun type_definition() { + val code = """export type Exact = { [K in keyof T]: T[K] };""" + TypeScriptAnalyser().analysis(code, "index.tsx") + } }