diff --git a/src/Language/TypeScript.hs b/src/Language/TypeScript.hs index 7a574b96c..37abf404b 100644 --- a/src/Language/TypeScript.hs +++ b/src/Language/TypeScript.hs @@ -69,7 +69,7 @@ termAssignment _ category children = | S.Indexed _ <- unwrap statements -> Just $ S.Export Nothing (toList (unwrap statements)) | otherwise -> Just $ S.Export (Just statements) [] - (For, _:_) -> Just $ S.For (init children) [last children] + (For, _:_) -> Just $ S.For (init children >>= unwrapExpressionStatements) [last children] (Function, children) -> case break ((== ExpressionStatements) . Info.category . extract) children of (inits, [body]) -> case inits of [id, callSignature] -> Just $ S.Function id (toList (unwrap callSignature)) (toList (unwrap body)) @@ -79,6 +79,9 @@ termAssignment _ category children = (Ty, children) -> Just $ S.Ty children (Interface, children) -> toInterface children _ -> Nothing + where unwrapExpressionStatements term + | Info.category (extract term) == ExpressionStatements = toList (unwrap term) + | otherwise = [term] categoryForTypeScriptName :: Text -> Category categoryForTypeScriptName category = case category of