Skip to content

Commit

Permalink
fix(ts): fix lodash issue in obj method param
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 12, 2022
1 parent dabffa7 commit 34c40da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
11 changes: 7 additions & 4 deletions chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ breakStatement
returnStatement
: Return ({this.notLineTerminator()}? expressionSequence)? eos
| Return '(' htmlElements ')' eos
// | Return '{' statement '}' eos
;

htmlElements
Expand Down Expand Up @@ -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
Expand All @@ -796,7 +797,7 @@ singleExpression
| '~' singleExpression # BitNotExpression
| '!' singleExpression # NotExpression
| Await singleExpression # AwaitExpression
| <assoc=right> singleExpression '**' singleExpression # PowerExpression
| <assoc=right> singleExpression '**' singleExpression # PowerExpression
| singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression
| singleExpression ('+' | '-') singleExpression # AdditiveExpression
| singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression
Expand Down Expand Up @@ -894,8 +895,8 @@ numericLiteral
identifierName
: Identifier
| reservedWord
| Lodash Lodash*
| Dollar Dollar*
| Lodash Lodash?
| Dollar Dollar?
;

identifierOrKeyWord
Expand All @@ -904,6 +905,8 @@ identifierOrKeyWord
| Require
| Module
| Default
| Lodash Lodash?
| Dollar Dollar?
;

reservedWord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1215,24 +1215,16 @@ const createTreeNode = <U = TreeNode, T extends JavaItem<T>>(): 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 <Text type={qualified ? undefined : "danger"}>{value}</Text>;
},
};
})
}
"""
val codeFile = TypeScriptAnalyser().analysis(code, "index.tsx")
Expand Down

0 comments on commit 34c40da

Please # to comment.