Angular 19 cannot build - Cannot read properties of undefined (reading 'kind') · Issue #58872 · angular/angular · GitHub
Skip to content

Angular 19 cannot build - Cannot read properties of undefined (reading 'kind') #58872

Closed

Description

@thaoula

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

18

Description

Hi Team,

I just upgraded Angular from v18 to v19 and I have trouble building all of the applications list in the Angular.json.

More specifically, I am getting the following error -

`✘ [ERROR] Cannot read properties of undefined (reading 'kind') [plugin angular-compiler]

node_modules/typescript/lib/typescript.js:30304:14:
  30304 │   return node.kind === 243 /* VariableStatement */;
        ╵               ^

at Object.isVariableStatement (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/typescript/lib/typescript.js:30304:15)
at UnusedStandaloneImportsRule.isPotentialSharedReference (file:///Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/compiler-cli/bundles/chunk-WLQBAON6.js:3404:16)
at UnusedStandaloneImportsRule.getUnusedSymbols (file:///Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/compiler-cli/bundles/chunk-WLQBAON6.js:3383:79)
at UnusedStandaloneImportsRule.checkNode (file:///Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/compiler-cli/bundles/chunk-WLQBAON6.js:3359:25)
at walk (file:///Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/compiler-cli/bundles/chunk-WLQBAON6.js:3453:38)
at visitNodes (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/typescript/lib/typescript.js:31791:22)
at forEachChildInSourceFile (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/typescript/lib/typescript.js:32004:12)
at forEachChild (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/typescript/lib/typescript.js:32304:35)
at SourceFileObject.forEachChild (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/typescript/lib/typescript.js:148907:12)
at SourceFileValidator.getDiagnosticsForFile (file:///Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/compiler-cli/bundles/chunk-WLQBAON6.js:3451:16)

This error came from the "onStart" callback registered here:

node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:107:18:
  107 │             build.onStart(async () => {
      ╵                   ~~~~~~~

at setup (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:107:19)
at async handlePlugins (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/esbuild/lib/main.js:1194:20)`

Minimal Reproduction

  1. use ng update to update working Angular 18 app.
  2. run ng build id --watch --preserve-symlinks --output-hashing=all

Exception or Error

✘ [ERROR] Cannot read properties of undefined (reading 'kind') [plugin angular-compiler]

    node_modules/typescript/lib/typescript.js:30304:14:
      30304 │   return node.kind === 243 /* VariableStatement */;
            ╵               ^

    at Object.isVariableStatement (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/typescript/lib/typescript.js:30304:15)
    at UnusedStandaloneImportsRule.isPotentialSharedReference (file:///Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/compiler-cli/bundles/chunk-WLQBAON6.js:3404:16)
    at UnusedStandaloneImportsRule.getUnusedSymbols (file:///Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/compiler-cli/bundles/chunk-WLQBAON6.js:3383:79)
    at UnusedStandaloneImportsRule.checkNode (file:///Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/compiler-cli/bundles/chunk-WLQBAON6.js:3359:25)
    at walk (file:///Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/compiler-cli/bundles/chunk-WLQBAON6.js:3453:38)
    at visitNodes (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/typescript/lib/typescript.js:31791:22)
    at forEachChildInSourceFile (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/typescript/lib/typescript.js:32004:12)
    at forEachChild (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/typescript/lib/typescript.js:32304:35)
    at SourceFileObject.forEachChild (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/typescript/lib/typescript.js:148907:12)
    at SourceFileValidator.getDiagnosticsForFile (file:///Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/compiler-cli/bundles/chunk-WLQBAON6.js:3451:16)

  This error came from the "onStart" callback registered here:

    node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:107:18:
      107 │             build.onStart(async () => {
          ╵                   ~~~~~~~

    at setup (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:107:19)
    at async handlePlugins (/Users/thaoula/projects/workbuddy/jms-platform/jms-web/node_modules/esbuild/lib/main.js:1194:20)

Your Environment

Angular CLI: 19.0.1
Node: 20.18.1
Package Manager: bun 1.1.36
OS: darwin arm64

Angular: 19.0.0
... animations, cdk, cdk-experimental, common, compiler
... compiler-cli, core, forms, localize, platform-browser
... platform-browser-dynamic, platform-server, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1900.1
@angular-devkit/core         19.0.1
@angular-devkit/schematics   19.0.1
@angular/build               19.0.1
@angular/cli                 19.0.1
@angular/ssr                 19.0.1
@schematics/angular          19.0.1
rxjs                         7.8.1
typescript                   5.6.3
zone.js                      0.15.0

Anything else relevant?

No response

Activity

  1. added this to the needsTriage milestone on Nov 25, 2024
  2. thaoula commented on Nov 28, 2024

    @thaoula
    Author

    Hi Team,

    Does anyone have any one have any suggestions to try and track down this issue.

    This issue is obviously not happening to everyone.

    Our project has multiple apps in a single angular.json file.

    All apps except 1 cannot build due to this error. However 1 of them does build. The codebase is quite large and I am not sure where to look in order to isolate the issue.

    I have tried again with the latest angular and the problem still exists.

    Kind regards,
    Tarek

  3. JeanMeche commented on Nov 28, 2024

    @JeanMeche
    Member

    It looks liks the issue orginiates from the new unused standalone import diagnostics.
    Until this is resolved, you can workaround an disable the diagnostic in your tsconfig with :

    {
      "angularCompilerOptions": {
        "extendedDiagnostics": {
          "checks": {
            "unusedStandaloneImports": "suppress"
          }
        }
      }
    }
    
  4. thaoula commented on Nov 28, 2024

    @thaoula
    Author

    Hi @JeanMeche,

    Many thanks for the tip. I have add the above to the tsconfig and I can now build all the projects.

    Kind Regards,
    Tarek

  5. added a commit that references this issue on Dec 6, 2024
    cd764a3
  6. added a commit that references this issue on Dec 6, 2024
    1b9492e
  7. angular-automatic-lock-bot commented on Jan 6, 2025

    @angular-automatic-lock-bot

    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.

  8. locked and limited conversation to collaborators on Jan 6, 2025
  9. added a commit that references this issue on Feb 7, 2025
    8184cdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions