Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
OliverJAsh opened this issue Feb 13, 2019 · 5 comments · Fixed by #38776
Closed

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

OliverJAsh opened this issue Feb 13, 2019 · 5 comments · Fixed by #38776
Labels
Bug A bug in TypeScript

Comments

@OliverJAsh
Copy link
Contributor

OliverJAsh commented Feb 13, 2019

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>;
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Feb 13, 2019
@Lenne231
Copy link

Lenne231 commented Mar 7, 2019

When using "Extract to function in module scope" the braces are missing as well.

@DanielRosenwasser
Copy link
Member

Thanks @a-tarasyuk!

@OliverJAsh
Copy link
Contributor Author

This still happens when using fragments: #44249

@a-tarasyuk
Copy link
Contributor

@OliverJAsh Ok, will check

@OliverJAsh
Copy link
Contributor Author

@a-tarasyuk I think I figured it out: #44252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants