Skip to content

Commit

Permalink
fix(ts): fix export issues
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Nov 17, 2022
1 parent 19bd271 commit 7474189
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package chapi.ast.typescriptast
import chapi.ast.antlr.TypeScriptParser
import chapi.ast.antlr.TypeScriptParser.IdentifierExpressionContext
import chapi.ast.antlr.TypeScriptParser.ParenthesizedExpressionContext
import chapi.ast.antlr.TypeScriptParser.VariableStatementContext
import chapi.domain.core.*
import chapi.infra.Stack
import org.antlr.v4.runtime.tree.TerminalNodeImpl
Expand Down Expand Up @@ -39,7 +40,7 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
this.namespaceName = ""
}

override fun enterVariableStatement(ctx: TypeScriptParser.VariableStatementContext?) {
override fun enterVariableStatement(ctx: VariableStatementContext?) {
val isExport = ctx!!.parent.parent.getChild(0).text == "export"

if (!isExport && ctx.variableDeclarationList() != null) {
Expand Down Expand Up @@ -941,6 +942,19 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
CodeProperty(TypeValue = typeValue, TypeType = "")
}?.toTypedArray() ?: arrayOf()


override fun enterExportElementDirectly(ctx: TypeScriptParser.ExportElementDirectlyContext?) {
when (val stmt = ctx?.declarationStatement()?.getChild(0)) {
is VariableStatementContext -> {
stmt.variableDeclarationList().variableDeclaration().forEach {
val text = it.identifierName().text
currentNode.Exports += CodeExport(text)
defaultNode.Exports += CodeExport(text)
}
}
}
}

override fun enterExportDefaultDeclaration(ctx: TypeScriptParser.ExportDefaultDeclarationContext?) {
val name = ctx!!.identifierName()
if (name != null) {
Expand Down

0 comments on commit 7474189

Please sign in to comment.