Skip to content

JSX: "extract to constant" generates invalid code #29890

@OliverJAsh

Description

@OliverJAsh

TypeScript Version: 3.3.1

Search Terms: jsx extract constant refactoring quick fix

Code

<Foo><Bar /></Foo>;

when selecting <Bar /> and actioning "extract to constant in enclosing scope"

Expected behavior:

const newLocal = <Bar />;
<Foo>{newLocal}</Foo>;

Actual behavior:

(missing braces)

const newLocal = <Bar />;
<Foo>newLocal</Foo>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions