Skip to content

Build Optimizer - Cannot read property 'kind' of undefined (isAngularDecoratorMetadataExpression) #15703

Closed
@alan-agius4

Description

@alan-agius4

🐞 Bug report

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Sort of, due to removal of tsickle & emit decorator metadata from libs

Description

Build optimizer fails with Cannot read property 'kind' of undefined

🔬 Minimal Reproduction

Paste the below in one of the tests in scrub-file_spec.ts

    import { __decorate } from 'tslib';
    import { Component, ElementRef, ContentChild, Injectable, NgModule } from '@angular/core';
    import { CommonModule } from '@angular/common';

      var FooBarComponent = /** @class */ (function () {
          function FooBarComponent(elementRef) {
              this.elementRef = elementRef;
              this.inlineButtons = [];
              this.menuButtons = [];
          }
          FooBarComponent.ctorParameters = function () { return [
              { type: ElementRef }
          ]; };
          __decorate([
              ContentChild('heading', { read: ElementRef, static: true })
          ], FooBarComponent.prototype, "buttons", void 0);
          FooBarComponent = __decorate([
              Component({
                  selector: 'custom-foo-bar',
                  template: "<h1 #heading>Foo-Bar!</h1>\n",
                  styles: ["h1{color:red;background-color:green;background-image:url(../styles/assets/test.png)}"]
              })
          ], FooBarComponent);
          return FooBarComponent;
      }());

🔥 Exception or Error


TypeError: Cannot read property 'kind' of undefined
  Stack:
        at 
        at isAngularDecoratorMetadataExpression (/Users/alan/git/angular-cli/packages/angular_devkit/build_optimizer/src/transforms/packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts:267:33)
        at checkNodeForDecorators (/Users/alan/git/angular-cli/packages/angular_devkit/build_optimizer/src/transforms/packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts:59:13)
        at visitNodes (/Users/alan/git/angular-cli/node_modules/typescript/lib/typescript.js:16631:30)
        at Object.forEachChild (/Users/alan/git/angular-cli/node_modules/typescript/lib/typescript.js:16857:24)
        at checkNodeForDecorators (/Users/alan/git/angular-cli/packages/angular_devkit/build_optimizer/src/transforms/packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts:50:21)
        at visitNode (/Users/alan/git/angular-cli/node_modules/typescript/lib/typescript.js:16622:24)
        at Object.forEachChild (/Users/alan/git/angular-cli/node_modules/typescript/lib/typescript.js:16752:21)
        at checkNodeForDecorators (/Users/alan/git/angular-cli/packages/angular_devkit/build_optimizer/src/transforms/packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts:50:21)
        at visitNode (/Users/alan/git/angular-cli/node_modules/typescript/lib/typescript.js:16622:24)
        at Object.forEachChild (/Users/alan/git/angular-cli/node_modules/typescript/lib/typescript.js:16809:24)
        at checkNodeForDecorators (/Users/alan/git/angular-cli/packages/angular_devkit/build_optimizer/src/transforms/packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts:50:21)
        at visitNode (/Users/alan/git/angular-cli/node_modules/typescript/lib/typescript.js:16622:24)
        at Object.forEachChild (/Users/alan/git/angular-cli/node_modules/typescript/lib/typescript.js:16820:24)
        at checkNodeForDecorators (/Users/alan/git/angular-cli/packages/angular_devkit/build_optimizer/src/transforms/packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts:50:21)
        at visitNode (/Users/alan/git/angular-cli/node_modules/typescript/lib/typescript.js:16622:24)
        at Object.forEachChild (/Users/alan/git/angular-cli/node_modules/typescript/lib/typescript.js:16716:21)

Anything else relevant?
This is related to this PR in ng-packagr ng-packagr/ng-packagr#1410

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions