google / google/closure-compiler

Infer when variables are "effectively const"

Open
#2,744 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

#2742 mentions the possibility of doing an early inference step where we look for variables that are assigned once and never mutated. We could add a very early check pass (potentially before module rewriting, even?) that added `@const` annotations to such variables' jsdoc. This would benefit NTI in that namespaces that aren't explicitly annotated as `@const` would get tighter inference. It could also simplify other passes, such as `InlineProperties`, which already builds in a similar check for determining when a property is inlineable.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.