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
@type
doesn't work on functions when a forward reference or requireType'd
#3549
Comments
I ran into this same bug a few weeks ago. It's caused by using a forward referenced type in an In your Goog Module case, the compiler sorts Here's an example without modules/provides (debugger link): /** @type {!Foo} */
const implBeforeFoo = (foo, bar) => [foo];
/** @typedef {function(!string, number):string} */
let Foo;
/** @type {!Foo} */
const implAfterFoo = (foo, bar) => [foo]; The compiler reports a type error on |
@type
doesn't work on functions when a forward reference or requireType'd
Is there a way to affect the file sort in the compiler? Is it just the order of |
Yes, it is just the order of the args. |
Swapping the order of the |
(going through old issues assigned to me) Unassigning myself, since I don't currently have bandwidth to work on Closure type system improvements |
Inline Case (working)
This has the typedef inline in a single file:
Compiler Args:
Result:
That's all well and good as expected.
Goog Module Case (broken)
Using
goog.module
results in the error not occurring:Compiler Args:
Result: No errors.
Expected result: Same error as above
Goog Provide Case (different result)
Compiler Args:
Result:
Expected result: Same error as inline case
I also noticed that if I move the
@type
annotation to the function expression that the compiler errors indicating that@type
is not supported on functions. Is the only solution to this to copy/paste the full function definition everywhere or is there a better alternative?Also, this may be related to #3041 but I was unsure.
compiler version: 20200204.0.0
library version: 20200204.0.0
The text was updated successfully, but these errors were encountered: