diff --git a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 index 172907de..ca96df5e 100644 --- a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 +++ b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 @@ -495,6 +495,7 @@ breakStatement returnStatement : Return ({this.notLineTerminator()}? expressionSequence)? eos | Return '(' htmlElements ')' eos +// | Return '{' statement '}' eos ; htmlElements @@ -776,7 +777,7 @@ singleExpression | singleExpression '[' expressionSequence ']' # MemberIndexExpression | singleExpression '?'? '!'? '.' '#'? identifierName nestedTypeGeneric? # MemberDotExpression // for: `onHotUpdateSuccess?.();` - | singleExpression '?'? '!'? '.' '#'? '(' identifierName? ')' # MemberDotExpression + | singleExpression '?'? '!'? '.' '#'? '(' identifierName? ')' # MemberDotExpression // samples: `error?.response?.data?.message ?? error.message;` | singleExpression '??' singleExpression # NullCoalesceExpression | singleExpression '!' # PropCheckExpression @@ -796,7 +797,7 @@ singleExpression | '~' singleExpression # BitNotExpression | '!' singleExpression # NotExpression | Await singleExpression # AwaitExpression - | singleExpression '**' singleExpression # PowerExpression + | singleExpression '**' singleExpression # PowerExpression | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression | singleExpression ('+' | '-') singleExpression # AdditiveExpression | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression @@ -894,8 +895,8 @@ numericLiteral identifierName : Identifier | reservedWord - | Lodash Lodash* - | Dollar Dollar* + | Lodash Lodash? + | Dollar Dollar? ; identifierOrKeyWord @@ -904,6 +905,8 @@ identifierOrKeyWord | Require | Module | Default + | Lodash Lodash? + | Dollar Dollar? ; reservedWord diff --git a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListenerTest.kt b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListenerTest.kt index 0e8d72f9..154636bc 100644 --- a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListenerTest.kt +++ b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListenerTest.kt @@ -1215,24 +1215,16 @@ const createTreeNode = >(): U => {}; @Test - internal fun typeIssue() { + internal fun lodashIssueInObjectMethod() { val code = """ -export interface CouplingRecord { - key: string; - label: string; - fullName: string; - name: string; - moduleId: string; - shortName: string; - props: { - desc: string; - name: string; - value: any; - key: string; - qualified: boolean; - }[]; - packages?: CouplingRecord[]; - classess?: CouplingRecord[]; +export default function CouplingList(props: CouplingListProps) { + const props = firstItem.props.map((prop, index) => { + return { + render(_: any, item: CouplingRecord) { + return {value}; + }, + }; + }) } """ val codeFile = TypeScriptAnalyser().analysis(code, "index.tsx")