Skip to content

Spread operator doesn't work in Angular generated project but runs in plain typescript #4688

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Nikki1993 opened this issue Feb 14, 2017 · 3 comments

Comments

@Nikki1993
Copy link

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Running this piece of code inside ngOnInit

const progressDefault = {
        bgRadius: 60,
        bgColor: this.colors.orange,
        rounded: false,
        reverse: false,
        animationSecs: 2,
        labels: [],
        segments: []
      };

      const object2 = {
        ...progressDefault
      };

      console.log(object2);

results in an error

./src/app/app.component.ts
Module build failed: TypeError: Cannot read property 'kind' of undefined
    at _getContentOfKeyLiteral (/Users/kononnik/git/alicia/node_modules/@ngtools/webpack/src/loader.js:9:13)
    at node.properties.some.prop (/Users/kononnik/git/alicia/node_modules/@ngtools/webpack/src/loader.js:205:56)
    at Array.some (native)
    at refactor.findAstNodes.filter (/Users/kononnik/git/alicia/node_modules/@ngtools/webpack/src/loader.js:205:43)
    at Array.filter (native)
    at _removeModuleId (/Users/kononnik/git/alicia/node_modules/@ngtools/webpack/src/loader.js:205:10)
    at Promise.resolve.then.then (/Users/kononnik/git/alicia/node_modules/@ngtools/webpack/src/loader.js:301:33)
    at process._tickCallback (internal/process/next_tick.js:103:7)
 @ ./src/app/app.module.ts 14:0-47
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

Expected behavior

Object properly copied and printed in the console like in this example https://www.typescriptlang.org/play/index.html#src=const%20ar%20%3D%20%7B%0D%0A%20%20%20%20text%3A%20'Hello'%0D%0A%7D%3B%0D%0A%0D%0Aconst%20ar2%20%3D%20%7B%0D%0A%20%20%20%20...ar%2C%0D%0A%20%20%20%20label%3A%20'Nikki'%0D%0A%7D%3B%0D%0A%0D%0Aconsole.log(ar)%3B%0D%0Aconsole.log(ar2)%3B

What is the motivation / use case for changing the behavior?

Please tell us about your environment:
macOS 10.12.3, Node 7.5.0 latest beta31 angular-cli

  • Angular version: 2.0.X
    2.4.7

  • Browser: Chrome 56 but fails alread at webpack compilation

  • Language: Typescript

@Meligy
Copy link
Contributor

Meligy commented Feb 14, 2017

Is this a duplicate of #4600?

If so, it should be fixed in #4642, which is merged in master, but not released yet.

@Nikki1993
Copy link
Author

@Meligy by the looks of it yea, weird, I tried searching for the error message before posting issue but nothing came up. Apologies for the dupe.

@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 Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants