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

Documentation of the ALL type (*) seems to be wrong #4025

Open
fingerartur opened this issue Jan 9, 2023 · 0 comments
Open

Documentation of the ALL type (*) seems to be wrong #4025

fingerartur opened this issue Jan 9, 2023 · 0 comments
Labels
triage-done Has been reviewed by someone on triage rotation.

Comments

@fingerartur
Copy link

It seems the documentation of the ALL type (*) 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:

/**
* @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;
@rishipal rishipal added the triage-done Has been reviewed by someone on triage rotation. label Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-done Has been reviewed by someone on triage rotation.
Projects
None yet
Development

No branches or pull requests

2 participants