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

Missing decorator throws "token must be defined" error in JIT #33637

Closed
kara opened this issue Nov 6, 2019 · 3 comments
Closed

Missing decorator throws "token must be defined" error in JIT #33637

kara opened this issue Nov 6, 2019 · 3 comments

Comments

@kara
Copy link
Contributor

@kara kara commented Nov 6, 2019

Currently, we throw token must be defined when a @Directive decorator is missing from a superclass that uses DI. This is because we are generating a factory function that calls directiveInject with an undefined token. Instead of generating this, we should generate the invalidFactory instruction (which will throw a friendlier error).

@kara kara added the comp: ivy label Nov 6, 2019
@ngbot ngbot bot added this to the needsTriage milestone Nov 6, 2019
@kara kara added the comp: compiler label Nov 6, 2019
@kara kara modified the milestones: needsTriage, v9-blockers Nov 6, 2019
@kara

This comment has been minimized.

Copy link
Contributor Author

@kara kara commented Nov 6, 2019

Proposed error message:

This constructor is not compatible with Angular Dependency Injection because dependency at index 'X' is invalid. 
This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.

Please check that 1) the type for dependency X is correct and 2) the correct Angular decorators are defined for this class and its ancestors.

Note that this is a dev mode error, so the length is not size-sensitive.

alxhub added a commit to alxhub/angular that referenced this issue Nov 11, 2019
Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes angular#33637
alxhub added a commit to alxhub/angular that referenced this issue Nov 15, 2019
Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes angular#33637
alxhub added a commit to alxhub/angular that referenced this issue Nov 19, 2019
Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes angular#33637
@kara

This comment has been minimized.

Copy link
Contributor Author

@kara kara commented Nov 22, 2019

Fixed by alxhub@2f8a0ec

@kara kara closed this Nov 22, 2019
alxhub added a commit to alxhub/angular that referenced this issue Dec 7, 2019
Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes angular#33637
AndrewKushnir added a commit that referenced this issue Dec 9, 2019
)

Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes #33637

PR Close #33739
AndrewKushnir added a commit to AndrewKushnir/angular that referenced this issue Dec 11, 2019
…ular#33739)

Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes angular#33637

PR Close angular#33739
AndrewKushnir added a commit that referenced this issue Dec 11, 2019
) (#34340)

Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes #33637

PR Close #33739

PR Close #34340
josephperrott added a commit to josephperrott/angular that referenced this issue Dec 11, 2019
…ular#33739)

Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes angular#33637

PR Close angular#33739
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Dec 23, 2019

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.