angular / vscode-ng-language-service

Angular extension for Visual Studio Code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No error for undefined variables when using *ngIf

enersis-pst opened this issue · comments

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)

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
thanks for the hint.
after i add "fullTemplateTypeCheck": true to my tsconfig it shows the error.

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

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

@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.

thanks thats what i need ;-)

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.