Skip to content
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

autoConst not producing const #1321

Open
danielbayley opened this issue Jul 13, 2024 · 1 comment
Open

autoConst not producing const #1321

danielbayley opened this issue Jul 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@danielbayley
Copy link
Contributor

danielbayley commented Jul 13, 2024

"civet autoConst"

  1. Does not work with destructuring, for example:
str = "string"
export {length} = str

fails to parse, instead of producing:

export const {length} = str
  1. Does not work with functions, for example:
export func = =>

does not produce:

export const func = () => {}
@edemaine
Copy link
Collaborator

edemaine commented Jul 13, 2024

Thanks for the report! There are two things going on here:

  1. {length} = str does not produce const {length} = str. It actually produces let, maybe via Hoist array binding and rest ref declarations. Fixes #1139. Fixes #1312 #1314?
  2. export {length} = str doesn't parse at all. It seems like a natural extension to export syntax though. We could transpile to const {length} = str; export {length}. Though without autoConst I'm not totally sure whether length should be exposed to the body like this...

@STRd6 STRd6 added the bug Something isn't working label Jul 15, 2024
@danielbayley danielbayley changed the title autoConst doesn’t work with destructuring autoConst not producing const Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants