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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

When code is sent inline to undefined attributes, the code is not linted. #1859

Closed
1 task
sne-jzabinski opened this issue Feb 6, 2023 · 2 comments
Closed
1 task
Labels

Comments

@sne-jzabinski
Copy link

馃悶 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

  • [x ] Angular Language Service VSCode extension
  • Angular Language Service server

Reproduction

Steps to reproduce the behavior:

  1. 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.
  2. In the example code, NewComponent is defined using new.cmpnt.ts and new.cmpnt.html. new.cmpnt.ts defines a variable: bob = 'bob';
  3. new.cmpnt.html accesses 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.
  4. 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.
  5. 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:

proper linting

Logs

No error is reported and the performance is fine, so no logs were collected.

馃實 Your Environment

Angular Version:


Angular CLI: 15.1.4
Node: 16.18.1
Package Manager: npm 8.19.2
OS: win32 x64

Angular: 15.1.3
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1501.4
@angular-devkit/build-angular   15.1.4
@angular-devkit/core            15.1.4
@angular-devkit/schematics      15.1.4
@angular/cli                    15.1.4
@schematics/angular             15.1.4
rxjs                            7.5.7
typescript                      4.9.5

Extension Version:


v15.1.0

VSCode Version:


Version: 1.75.0 (user setup)
Commit: e2816fe719a4026ffa1ee0189dc89bdfdbafb164
Date: 2023-02-01T15:23:45.584Z
Electron: 19.1.9
Chromium: 102.0.5005.194
Node.js: 16.14.2
V8: 10.2.154.23-electron.0
OS: Windows_NT x64 10.0.19045
Sandboxed: Yes

Operating System:


Windows 10 Pro, 22H2

Extension options:


// 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,

@atscott
Copy link
Collaborator

atscott commented Feb 6, 2023

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

This is effectively a duplicate of angular/angular#3425 / angular/angular#2014 / angular/angular#46351 and an issue with Angular's template syntax, directive matching, and compiler in general rather than the language service itself.

@atscott atscott closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2023
@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 Mar 9, 2023
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