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

No error for undefined variables when using *ngIf #1985

Closed
enersis-pst opened this issue Dec 21, 2023 · 7 comments
Closed

No error for undefined variables when using *ngIf #1985

enersis-pst opened this issue Dec 21, 2023 · 7 comments
Labels

Comments

@enersis-pst
Copy link

Description

Not existing variables woudnt show an error. This is the case of elements which parent have a *ngIf.

In this example the variable context_ doesnt exist. But for the neasted element this woudnt show an error.

{{ context_ }}
<ng-container *ngIf="context_">
  {{ context_ }}
</ng-container>
{{ context_ }}
image

🌍 Your Environment

Angular Version: 16.1
Angular Language Service: 17.0.3
@angular-devkit/architect 0.1602.10
@angular-devkit/build-angular 16.2.10
@angular-devkit/core 16.2.10
@angular-devkit/schematics 16.1.8
@angular/cli 16.1.8
@schematics/angular 16.1.8
rxjs 7.8.1
typescript 5.1.6
zone.js 0.13.3

Extension Version:
17.0.3

VSCode Version:
1.85.1

Operating System:
macos 12.3.1 (21E258)

@atscott
Copy link
Collaborator

atscott commented Dec 21, 2023

Thanks for reporting this issue. However, you didn't provide sufficient information for us to understand and reproduce the problem. It seems likely that your project is not using strict template type checking.

Please check out our submission guidelines to understand why we can't act on issues that are lacking important information.

If the problem still exists in your application, please open a new issue and follow the instructions in the issue template.

@atscott atscott closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2023
@enersis-pst
Copy link
Author

@atscott
thanks for the hint.
after i add "fullTemplateTypeCheck": true to my tsconfig it shows the error.

@atscott
Copy link
Collaborator

atscott commented Dec 21, 2023

fullTemplateTypeCheck is deprecated and actually skips a lot of checks: https://angular.io/guide/angular-compiler-options#fulltemplatetypecheck. The option you want is "strictTemplates": true

@enersis-pst
Copy link
Author

i think i have to clean much code firstly ;-)

@atscott
Copy link
Collaborator

atscott commented Dec 21, 2023

@enersis-pst There is also an extension option to force strict templates without changing your tsconfig. This does mean that you are choosing to use compiler options for the language service that differ from what's used in the application so you will see more errors. But at least you can continue compiling and running the application and fix things as you see them.

@enersis-pst
Copy link
Author

thanks thats what i need ;-)

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

No branches or pull requests

2 participants