Skip to content

Commit

Permalink
fix(grammar-ts): fix any in objectLiteral type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 12, 2022
1 parent 0369682 commit ad68a8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
5 changes: 3 additions & 2 deletions chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ typeArgument

type_
: (Keyof | Typeof)* unionOrIntersectionOrPrimaryType
| unionOrIntersectionOrPrimaryType
| functionType
| constructorType
| typeGeneric
Expand Down Expand Up @@ -168,7 +169,6 @@ typeMember
| methodSignature ('=>' type_)?
| enumSignature
| '[' typeReference In typeReference ']' typeAnnotation
// | objectSignature
;

arrayType
Expand Down Expand Up @@ -909,7 +909,7 @@ identifierOrKeyWord
| Module
| Default
| Lodash Lodash?
| Dollar Dollar?
| Any
;

reservedWord
Expand Down Expand Up @@ -972,6 +972,7 @@ keyword
| TypeAlias
| String
| Undefined
| Any
;

getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,26 @@ const docs = {
@Test
internal fun keyofTypeOf() {
val code = """
const getClazzColumnsBy = (type: keyof typeof columnCount) => {
const getClazzColumnsBy = (type: keyof typeof columnCount) => {}
"""
val codeFile = TypeScriptAnalyser().analysis(code, "index.tsx")
assertEquals(1, codeFile.DataStructures.size)
}

@Test
internal fun someIssue() {
val code = """
export function getChartsOption(data?: number[]): EChartOption {
return {
series: !data ? defaultSeriesMarkLineOpt :
[...defaultSeriesMarkLineOpt, {
data: [data],
tooltip: {
formatter: ({ value }: any) => {}
}
},
]
}
}
"""
val codeFile = TypeScriptAnalyser().analysis(code, "index.tsx")
Expand Down

0 comments on commit ad68a8a

Please # to comment.