Skip to content

Cannot read properties of undefined (reading 'text') transforming switch statement with transformer #1464

@Perryvw

Description

@Perryvw

We are using node.getChildren() which appears to be able to return undefined when running it on a node produced by a transformer. This causes the transpiler to fail with an undefined reference:

TypeError: Cannot read properties of undefined (reading 'text')
    at createChildren (C:\scratch\amethyst\node_modules\typescript\lib\typescript.js:139469:58)
    at NodeObject.getChildren (C:\scratch\amethyst\node_modules\typescript\lib\typescript.js:141026:54)
    at containsBreakOrReturn (C:\scratch\amethyst\node_modules\typescript-to-lua\dist\transformation\visitors\switch.js:14:55)
    at transformSwitchStatement (C:\scratch\amethyst\node_modules\typescript-to-lua\dist\transformation\visitors\switch.js:128:46)
    at TransformationContext.transformNodeRaw (C:\scratch\amethyst\node_modules\typescript-to-lua\dist\transformation\context\context.js:65:24)
    at TransformationContext.transformNode (C:\scratch\amethyst\node_modules\typescript-to-lua\dist\transformation\context\context.js:45:56)
    at C:\scratch\amethyst\node_modules\typescript-to-lua\dist\transformation\context\context.js:100:37
    at Array.flatMap (<anonymous>)
    at TransformationContext.transformStatements (C:\scratch\amethyst\node_modules\typescript-to-lua\dist\transformation\context\context.js:98:45)
    at transformFunctionBodyContent (C:\scratch\amethyst\node_modules\typescript-to-lua\dist\transformation\visitors\function.js:79:74)
    ```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions