google / google/closure-compiler
Documentation of the ALL type (*) seems to be wrong
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
It seems [the documentation of the ALL type (*)](https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System) is wrong. It states the following:
_Indicates that the variable can take on any type. However, it is an error to attempt to do operations on a value of this type or access any properties on it. You also cannot assign it to any other type variable without a cast._
This type checking works only when I use the compilation option `--jscomp_error=strictCheckTypes`. When I do not use it I can freely access properties, etc. So I am guessing the doc needs a note about the fact that this option must be enabled.
Example without `strictCheckTypes` option:
```js
/**
* @type {*}
*/
const x = 1
/**
* @type {number}
*/
const y = x.toString() // This should raise error but does not
```
Compiler Version: v20221102
Build command:
```
java -jar ./scripts/closureCompiler.jar \
--entry_point=./src/js/index.js \
--js=./src/**.js \
--dependency_mode=PRUNE \
--warning_level=VERBOSE \
--js_output_file=./dist/bundle.js \
--module_resolution=WEBPACK \
--compilation_level=ADVANCED \
--jscomp_error=checkDebuggerStatement \
--jscomp_error=unusedLocalVariables \
--jscomp_error=reportUnknownTypes;
```
Contributor guide
Assessment
This issue has not been assessed yet.