angular / vscode-ng-language-service

Angular extension for Visual Studio Code
MIT License
781 stars 117 forks source link

Language server crash on duplicate decorated properties #2091

Open SarenDev opened 1 month ago

SarenDev commented 1 month ago

šŸž bug report

Is this a regression?

This bug does not appear to be a regression from v18.0.0

Description

The language server crashes with an assertion of "Expected successfully analyzed compilation" when a duplicate decorated property is found in a component.

import { Component, Input } from '@angular/core';
import { RouterOutlet } from '@angular/router';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet],
  templateUrl: './app.component.html',
  styleUrl: './app.component.css',
})
export class AppComponent {
  @Input({ required: true }) message: string = '';
  @Input({ required: true }) error: boolean = false;
  @Input({ required: true }) error: boolean = false;
}

Bug Type

What does this bug affect

Reproduction

Steps to reproduce the behavior:

  1. Create a component with two @Input properties using the same name
  2. (in VSCode) Save the file to execute a check
  3. See error

Expected behavior

The language server flags the error in the code and continues running without triggering assertions and restarting.

Logs

The Angular Language Service debug-level log did not indicate any error before getting cleared on every restart. Below is the output of the Angular Language Service provided by the Output VSCode tab


[Info  - 12:41:32 PM] Angular language server process ID: 60819
[Info  - 12:41:32 PM] Imported typescript/lib/tsserverlibrary is version 5.5.3.
[Info  - 12:41:32 PM] Using @angular/language-service v18.2.0-rc.0 from /Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/index.js
[Info  - 12:41:32 PM] Log file: /Users/saren/Library/Application Support/Code/logs/20241003T115223/window3/exthost/Angular.ng-template/nglangsvc.log
[Info  - 12:41:33 PM] Enabling language service for /Users/saren/test/crash/tsconfig.json.
/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:41043
            throw new Error(`Duplicate decorated properties found on class '${clazz.name.text}': ` +
                  ^

Error: Duplicate decorated properties found on class 'AppComponent': error
    at extractClassMetadata (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:41043:19)
    at ComponentDecoratorHandler.analyze (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:54554:27)
    at TraitCompiler.analyzeTrait (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:38124:40)
    at analyze (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:38090:44)
    at TraitCompiler.analyzeClass (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:38112:21)
    at visit (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:37889:26)
    at visitNodes (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/typescript/lib/typescript.js:31715:22)
    at forEachChildInSourceFile (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/typescript/lib/typescript.js:31928:12)
    at Object.forEachChild (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/typescript/lib/typescript.js:32228:35)
    at visit (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:37891:40)

Node.js v20.15.1
[Info  - 12:41:48 PM] Connection to server got closed. Server will restart.
[Info  - 12:41:48 PM] Angular language server process ID: 60925
[Info  - 12:41:48 PM] Imported typescript/lib/tsserverlibrary is version 5.5.3.
[Info  - 12:41:48 PM] Using @angular/language-service v18.2.0-rc.0 from /Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/index.js
[Info  - 12:41:48 PM] Log file: /Users/saren/Library/Application Support/Code/logs/20241003T115223/window3/exthost/Angular.ng-template/nglangsvc.log
[Info  - 12:41:49 PM] Enabling language service for /Users/saren/test/crash/tsconfig.json.
[Error - 12:41:50 PM] Request textDocument/foldingRange failed.
  Message: Request textDocument/foldingRange failed with message: Duplicate decorated properties found on class 'AppComponent': error
  Code: -32603 
/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:58296
                throw new Error(`AssertionError: Expected successfully analyzed compilation.`);
                      ^

Error: AssertionError: Expected successfully analyzed compilation.
    at IncrementalCompilation.priorTypeCheckingResultsFor (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:58296:23)
    at TemplateTypeCheckerImpl.maybeAdoptPriorResultsForFile (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:53624:53)
    at /Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:53657:22
    at DelegatingPerfRecorder.inPhase (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:37692:24)
    at TemplateTypeCheckerImpl.ensureAllShimsForOneFile (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:53656:23)
    at TemplateTypeCheckerImpl.getDiagnosticsForFile (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:53494:26)
    at NgCompiler.getTemplateDiagnosticsForFile (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:63533:69)
    at NgCompiler.getDiagnosticsForFile (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:63089:42)
    at /Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:69171:56
    at /Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:69488:71

Node.js v20.15.1
[Info  - 12:41:50 PM] Connection to server got closed. Server will restart.
[Info  - 12:41:51 PM] Angular language server process ID: 60950
[Info  - 12:41:51 PM] Imported typescript/lib/tsserverlibrary is version 5.5.3.
[Info  - 12:41:51 PM] Using @angular/language-service v18.2.0-rc.0 from /Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/index.js
[Info  - 12:41:51 PM] Log file: /Users/saren/Library/Application Support/Code/logs/20241003T115223/window3/exthost/Angular.ng-template/nglangsvc.log
[Info  - 12:41:51 PM] Enabling language service for /Users/saren/test/crash/tsconfig.json.
[Error - 12:41:51 PM] Request textDocument/foldingRange failed.
  Message: Request textDocument/foldingRange failed with message: Duplicate decorated properties found on class 'AppComponent': error
  Code: -32603 
[Error - 12:42:12 PM] Request textDocument/foldingRange failed.
  Message: Request textDocument/foldingRange failed with message: Duplicate decorated properties found on class 'AppComponent': error
  Code: -32603 
/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:58296
                throw new Error(`AssertionError: Expected successfully analyzed compilation.`);
                      ^

Error: AssertionError: Expected successfully analyzed compilation.
    at IncrementalCompilation.priorTypeCheckingResultsFor (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:58296:23)
    at TemplateTypeCheckerImpl.maybeAdoptPriorResultsForFile (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:53624:53)
    at /Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:53657:22
    at DelegatingPerfRecorder.inPhase (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:37692:24)
    at TemplateTypeCheckerImpl.ensureAllShimsForOneFile (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:53656:23)
    at TemplateTypeCheckerImpl.getDiagnosticsForFile (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:53494:26)
    at NgCompiler.getTemplateDiagnosticsForFile (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:63533:69)
    at NgCompiler.getDiagnosticsForFile (/Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:63089:42)
    at /Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:69171:56
    at /Users/saren/.vscode/extensions/angular.ng-template-18.2.0/node_modules/@angular/language-service/bundles/language-service.js:69488:71

šŸŒ Your Environment

Angular Version:


Angular CLI: 18.2.7
Node: 22.9.0
Package Manager: npm 10.8.3
OS: darwin arm64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1802.7
@angular-devkit/build-angular   18.2.7
@angular-devkit/core            18.2.7
@angular-devkit/schematics      18.2.7
@schematics/angular             18.2.7
rxjs                            7.8.1
typescript                      5.5.4
zone.js                         0.14.10

Extension Version:


v18.2.0

VSCode Version:


Version: 1.93.1
Commit: 38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
Date: 2024-09-11T17:20:05.685Z
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Darwin arm64 24.0.0

Operating System:


MacOS 15.0 (24A335)

Extension options:


"angular.log": "verbose"