Skip to content

getExpressionOrThrow no longer exists on JsxElement in v16 #1325

@oshi97

Description

@oshi97

Describe the bug

Version: 16.0.0

To Reproduce

getExpressionOrThrow no longer exists on JsxElement in v16. This doesn't appear to be present in the release notes for the 16.0.0 breaking changes

import { SyntaxKind, JsxAttribute } from 'ts-morph'

function doJsxThing(n: JsxAttribute) {
  const initializer = n.getInitializerOrThrow()
  if (initializer.isKind(SyntaxKind.StringLiteral)) {
    return
  }
  // no longer compiles
  const expression = initializer.getExpressionOrThrow()
}

Expected behavior

I think the code should compile if this isn't an expected change. Otherwise would appreciate an alternative!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions