You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You'll need to download the example project and open it in a version of VSCode running the extension in order to see this issue.
In the example code, NewComponent is defined using new.cmpnt.ts and new.cmpnt.html. new.cmpnt.ts defines a variable: bob = 'bob';
new.cmpnt.htmlaccesses a variable that does not exist, like so: shouldnotwork = 'bob'. Notice the lack of red squiggly under shouldnotwork. Try changing the code sent to *ngIf to something else, like unknownFunction(). Notice that no linting occurs for that either.
Although no error appears, the true underlying issue is that the module housing NewComponent lacks an import of the module housing code for *ngIf. The missing module is CommonModule. In the module code, uncomment the line importing CommonModule.
Go back to new.cmpnt.html: notice that the code being sent to *ngIf is now linted.
Expected behavior
Code should be linted regardless of whether it is being sent to an unrecognized attribute. It would also be great if unrecognized attributes could be noted for users by the linter.
Screenshots
When things work as expected, the error looks like this:
Logs
No error is reported and the performance is fine, so no logs were collected.
// Disable the step to automatically run ngcc. [ngcc](https://github.com/angular/angular/blob/main/packages/compiler/design/architecture.md#high-level-proposal) is required to run and gather metadata from libraries not published with Ivy instructions. This can be run outside of VSCode instead (for example, as part of the build/rebuild in the CLI). Note that ngcc needs to run not only at startup, but also whenever the dependencies change. Failing to run ngcc when required can result in incomplete information and spurious errors reported by the language service.
"angular.disableAutomaticNgcc": false,
// Prompt to enable the [strictTemplates](https://angular.io/guide/angular-compiler-options#stricttemplates) flag in [angularCompilerOptions](https://angular.io/guide/angular-compiler-options). Note that strict mode is only available when using Ivy.
"angular.enable-strict-mode-prompt": true,
// Enabling this option will force the language service to use [strictTemplates](https://angular.io/guide/angular-compiler-options#stricttemplates) and ignore the user settings in the `tsconfig.json`.
"angular.forceStrictTemplates": false,
// Enables logging of the Angular server to a file. This log can be used to diagnose Angular Server issues. The log may contain file paths, source code, and other potentially sensitive information from your project.
"angular.log": "off",
// Enable/disable showing completions on potentially undefined values that insert an optional chain call. Requires TS 3.7+, strict null checks to be enabled and the `legacy View Engine` option to be disabled.
"angular.suggest.includeAutomaticOptionalChainCompletions": true,
// Enable/disable snippet completions from Angular language server. Requires using TypeScript 4.3+ in the workspace and the `legacy View Engine` option to be disabled.
"angular.suggest.includeCompletionsWithSnippetText": true,
// Traces the communication between VS Code and the Angular language server.
"angular.trace.server": "off",
// Use legacy View Engine language service. This option is incompatible with projects using Angular v13 and above.
"angular.view-engine": false,
The text was updated successfully, but these errors were encountered:
Thanks providing a helpful reproduction! This is working as expected. Since *ngIf was not imported, it is not recognized as a template binding. This is just a regular attribute so everything in the quotes is just plain text. Specifically for common microsyntax directives like *ngIf and *ngFor, this experience is slightly improved when using standalone components.
馃悶 bug report
Is this a regression?
Don't know
Description
When code is sent inline to unrecognized attributes, the code is not linted.
Example project
Bug Type
What does this bug affect
Reproduction
Steps to reproduce the behavior:
NewComponent
is defined usingnew.cmpnt.ts
andnew.cmpnt.html
. new.cmpnt.ts defines a variable:bob = 'bob';
new.cmpnt.html
accesses a variable that does not exist, like so:shouldnotwork = 'bob'
. Notice the lack of red squiggly undershouldnotwork
. Try changing the code sent to*ngIf
to something else, likeunknownFunction()
. Notice that no linting occurs for that either.NewComponent
lacks animport
of the module housing code for*ngIf
. The missing module isCommonModule
. In the module code, uncomment the line importingCommonModule
.new.cmpnt.html
: notice that the code being sent to *ngIf is now linted.Expected behavior
Code should be linted regardless of whether it is being sent to an unrecognized attribute. It would also be great if unrecognized attributes could be noted for users by the linter.
Screenshots
When things work as expected, the error looks like this:
Logs
No error is reported and the performance is fine, so no logs were collected.
馃實 Your Environment
Angular Version:
Extension Version:
VSCode Version:
Operating System:
Extension options:
The text was updated successfully, but these errors were encountered: