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

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

Closed
alan-agius4 opened this issue Sep 27, 2019 · 2 comments 路 Fixed by #15705
Closed

Comments

@alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Sep 27, 2019

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

@alan-agius4

This comment has been minimized.

Copy link
Collaborator Author

@alan-agius4 alan-agius4 commented Sep 27, 2019

Note: apart from fixing the error we need to make sure that Angular decorators are dropped.

alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Sep 28, 2019
鈥 no `__metadata`

When a `__decorator` expression has no `__metadata` call, example:

```js
__decorate([
    ContentChild('heading', { read: ElementRef, static: true })
], FooBarComponent.prototype, "buttons", void 0);
```

A `Cannot read property 'kind' of undefined` error will be thrown.

Closes: angular#15703
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Sep 28, 2019
鈥 no `__metadata`

When a `__decorator` expression has no `__metadata` call, example:

```js
__decorate([
    ContentChild('heading', { read: ElementRef, static: true })
], FooBarComponent.prototype, "buttons", void 0);
```

A `Cannot read property 'kind' of undefined` error will be thrown.

Closes: angular#15703
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Sep 29, 2019
鈥 no `__metadata`

When a `__decorator` expression has no `__metadata` call, example:

```js
__decorate([
    ContentChild('heading', { read: ElementRef, static: true })
], FooBarComponent.prototype, "buttons", void 0);
```

A `Cannot read property 'kind' of undefined` error will be thrown.

Closes: angular#15703
vikerman added a commit that referenced this issue Oct 1, 2019
鈥 no `__metadata`

When a `__decorator` expression has no `__metadata` call, example:

```js
__decorate([
    ContentChild('heading', { read: ElementRef, static: true })
], FooBarComponent.prototype, "buttons", void 0);
```

A `Cannot read property 'kind' of undefined` error will be thrown.

Closes: #15703
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Oct 2, 2019
鈥 no `__metadata`

When a __decorator expression has no __metadata call, example:

```
__decorate([
    ContentChild('heading', { read: ElementRef, static: true })
], FooBarComponent.prototype, "buttons", void 0);
```

A Cannot read property 'kind' of undefined error will be thrown.

Closes: angular#15703
vikerman added a commit that referenced this issue Oct 2, 2019
鈥 no `__metadata`

When a __decorator expression has no __metadata call, example:

```
__decorate([
    ContentChild('heading', { read: ElementRef, static: true })
], FooBarComponent.prototype, "buttons", void 0);
```

A Cannot read property 'kind' of undefined error will be thrown.

Closes: #15703
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Nov 1, 2019

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 Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant
You can鈥檛 perform that action at this time.