Skip to content

Object spread results in 'Cannot read property 'kind' of undefined' error. #4600

@jinder

Description

@jinder

OS?

Mac OSX Sierra

Versions.

@angular/cli: 1.0.0-beta.31
node: 7.5.0
os: darwin x64
@angular/common: 4.0.0-beta.7
@angular/compiler: 4.0.0-beta.7
@angular/core: 4.0.0-beta.7
@angular/forms: 4.0.0-beta.7
@angular/http: 4.0.0-beta.7
@angular/platform-browser: 4.0.0-beta.7
@angular/platform-browser-dynamic: 4.0.0-beta.7
@angular/router: 4.0.0-beta.7
@angular/cli: 1.0.0-beta.31
@angular/compiler-cli: 4.0.0-beta.7

Repro steps.

Create a file using the reducer snippet below. Run ng build.

The log given by the failure.

Module build failed: TypeError: Cannot read property 'kind' of undefined
    at _getContentOfKeyLiteral (/Users/jinder/git/kangaroom-web/node_modules/@ngtools/webpack/src/loader.js:9:13)
    at node.properties.some.prop (/Users/jinder/git/kangaroom-web/node_modules/@ngtools/webpack/src/loader.js:205:56)
    at Array.some (native)
    at refactor.findAstNodes.filter (/Users/jinder/git/kangaroom-web/node_modules/@ngtools/webpack/src/loader.js:205:43)
    at Array.filter (native)
    at _removeModuleId (/Users/jinder/git/kangaroom-web/node_modules/@ngtools/webpack/src/loader.js:205:10)
    at Promise.resolve.then.then (/Users/jinder/git/kangaroom-web/node_modules/@ngtools/webpack/src/loader.js:301:33)
    at process._tickCallback (internal/process/next_tick.js:103:7)
 @ ./src/app/app.reducer.ts 34:0-55
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi ./src/main.ts

Mention any other details that might be useful.

This only occurs when doing a normal build. If you use --aot, the error doesn't happen. Error only seems to occur when using object spread syntax in my reducer. If I comment out the spread syntax, it will build without error.

export function reducer(state = initialState, action: layout.Actions): State {
  switch (action.type) {
    case layout.ActionTypes.CloseMenu:
      return { ...state, showMenu: false };

    default:
      return state;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfultype: bug/fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions