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

[Angular] The template context does not have an implicit value #251

Closed
wangming-0215 opened this issue May 18, 2018 · 3 comments
Closed
Labels

Comments

@wangming-0215
Copy link

Hi, here's an error I encounter regularly. Here is my code:
qq 20180519023703
qq 20180519023736

@prasworld
Copy link

Check this solution

Apress/pro-angular-6#6

@kyliau kyliau added the bug label Nov 23, 2019
@ayazhafiz
Copy link
Member

I don't think this is a bug. In a static analysis, the type of the context used by the embedded template (TemplateRef) can't be refined more than the type parameter of the TemplateRef used by the structural directive - in this case, since the type of the context is specified to be Object, the language service doesn't have a good way of knowing that the actual context used is CounterDirectiveContext. Specifying CounterDirectiveContext does get rid of the diagnostic message.

I think an effective action we can take is to provide a more helpful diagnostic message, perhaps including a suggestion to refine the type of the context used by the TemplateRef.

ayazhafiz added a commit to ayazhafiz/angular that referenced this issue Jan 12, 2020
This commit elaborates diagnostics produced for invalid template
contexts by including the name of the embedded template type using the
template context, and in the common case that the implicity property is
being referenced (e.g. in a `for .. of ..` expression), suggesting to
refine the type of the context. This suggestion is provided because
users will sometimes use a base class as the type of the context in the
embedded view, and a more specific context later on (e.g. in an
`ngOnChanges` method).

Closes angular/vscode-ng-language-service#251
ayazhafiz added a commit to ayazhafiz/angular that referenced this issue Jan 23, 2020
This commit elaborates diagnostics produced for invalid template
contexts by including the name of the embedded template type using the
template context, and in the common case that the implicity property is
being referenced (e.g. in a `for .. of ..` expression), suggesting to
refine the type of the context. This suggestion is provided because
users will sometimes use a base class as the type of the context in the
embedded view, and a more specific context later on (e.g. in an
`ngOnChanges` method).

Closes angular/vscode-ng-language-service#251
AndrewKushnir pushed a commit to angular/angular that referenced this issue Jan 23, 2020
…gs (#34751)

This commit elaborates diagnostics produced for invalid template
contexts by including the name of the embedded template type using the
template context, and in the common case that the implicity property is
being referenced (e.g. in a `for .. of ..` expression), suggesting to
refine the type of the context. This suggestion is provided because
users will sometimes use a base class as the type of the context in the
embedded view, and a more specific context later on (e.g. in an
`ngOnChanges` method).

Closes angular/vscode-ng-language-service#251

PR Close #34751
sonukapoor pushed a commit to sonukapoor/angular that referenced this issue Feb 13, 2020
…gs (angular#34751)

This commit elaborates diagnostics produced for invalid template
contexts by including the name of the embedded template type using the
template context, and in the common case that the implicity property is
being referenced (e.g. in a `for .. of ..` expression), suggesting to
refine the type of the context. This suggestion is provided because
users will sometimes use a base class as the type of the context in the
embedded view, and a more specific context later on (e.g. in an
`ngOnChanges` method).

Closes angular/vscode-ng-language-service#251

PR Close angular#34751
@angular-automatic-lock-bot
Copy link

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 Feb 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants