We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I think this looks like a bug in the compiler, see the minimal test case below.
The function parameter has a default, so it may never be "undefined" and the compiler honours this.
What I didn't expect is that enclosed in a function it somehow it picks up the possibility to be "undefined".
It happens for a range of types; function, string etc. The case where I noticed was a callback function provided to a constructor.
If I'm mistaken and this is not a bug but actually some edge case of the language then I'd also be open to hear of that. Many thanks.
/** * @param {string} v */ function outer(v = 'fallback') { inner(v); // <-- string function local() { inner(v); // <-- string|undefined ??? } } /** * @param {string} v */ function inner(v) { console.log(v); } outer();
$ java -jar closure-compiler-v20230502.jar -O ADVANCED test.js test.js:9:14: WARNING - [JSC_TYPE_MISMATCH] actual parameter 1 of inner does not match formal parameter found : (string|undefined) required: string 9| inner(v); ^ 0 error(s), 1 warning(s), 100.0% typed (function(a="fallback"){console.log(a)})();
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I think this looks like a bug in the compiler, see the minimal test case below.
The function parameter has a default, so it may never be "undefined" and the compiler honours this.
What I didn't expect is that enclosed in a function it somehow it picks up the possibility to be "undefined".
It happens for a range of types; function, string etc. The case where I noticed was a callback function provided to a constructor.
If I'm mistaken and this is not a bug but actually some edge case of the language then I'd also be open to hear of that. Many thanks.
The text was updated successfully, but these errors were encountered: