-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Use const rather than var when target es6 #6597
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
Use const rather than var when target es6 #6597
Conversation
fetch latest code
fetch latest code
…on and the target is es6
src/compiler/emitter.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<= ScriptTarget.ES5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/compiler/emitter.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you wrap this in a helper method, since you repeat this pattern 3 times in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name (emitVar) is misleading and we probably don't need the function at all.
I'd prefer to just have a local in this function const varOrConst = (languageVersion <= ScriptTarget.ES5) ? 'var ' : 'const ';) and write(varOrConst) at these call sites.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
👍 |
|
👍 Thanks! |
…hen_target_es6 Use const rather than var when target es6
#6092