Skip to content

Exception transforming optional array?.push with single element #1256

@Perryvw

Description

@Perryvw
[1]?.push(4);

Causes an exception:

TypeError: Cannot read property 'kind' of undefined

      27 | export function findFirstNonOuterParent(node: ts.Node): ts.Node {
      28 |     let current = node.parent;
    > 29 |     while (ts.isOuterExpression(current)) {
         |               ^
      30 |         current = current.parent;
      31 |     }
      32 |     return current;

      at Object.isOuterExpression (node_modules/typescript/lib/typescript.js:29305:22)
      at findFirstNonOuterParent (src/transformation/utils/typescript/index.ts:29:15)
      at transformSingleElementArrayPush (src/transformation/builtins/array.ts:44:79)
      at transformArrayPrototypeCall (src/transformation/builtins/array.ts:96:28)
      at transformBuiltinCallExpression (src/transformation/builtins/index.ts:138:43)
      at Object.transformCallExpression [as transform] (src/transformation/visitors/call.ts:232:39)
      at TransformationContext.transformNode (src/transformation/context/context.ts:75:52)
      at TransformationContext.transformExpression (src/transformation/context/context.ts:92:31)
      at src/transformation/visitors/optional-chaining.ts:133:30
      at transformInPrecedingStatementScope (src/transformation/utils/preceding-statements.ts:8:35)

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