{"action":"opened","issue":{"url":"https://api.github.com/repos/angular/devkit/issues/474","repository_url":"https://api.github.com/repos/angular/devkit","labels_url":"https://api.github.com/repos/angular/devkit/issues/474/labels{/name}","comments_url":"https://api.github.com/repos/angular/devkit/issues/474/comments","events_url":"https://api.github.com/repos/angular/devkit/issues/474/events","html_url":"https://github.com/angular/devkit/issues/474","id":301502814,"number":474,"title":"schematic() doesn't copy options correctly when one is an object or null","user":{"login":"james-schwartzkopf","id":21959477,"avatar_url":"https://avatars2.githubusercontent.com/u/21959477?v=4","gravatar_id":"","url":"https://api.github.com/users/james-schwartzkopf","html_url":"https://github.com/james-schwartzkopf","followers_url":"https://api.github.com/users/james-schwartzkopf/followers","following_url":"https://api.github.com/users/james-schwartzkopf/following{/other_user}","gists_url":"https://api.github.com/users/james-schwartzkopf/gists{/gist_id}","starred_url":"https://api.github.com/users/james-schwartzkopf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/james-schwartzkopf/subscriptions","organizations_url":"https://api.github.com/users/james-schwartzkopf/orgs","repos_url":"https://api.github.com/users/james-schwartzkopf/repos","events_url":"https://api.github.com/users/james-schwartzkopf/events{/privacy}","received_events_url":"https://api.github.com/users/james-schwartzkopf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-01T18:01:23Z","updated_at":"2018-03-01T18:01:23Z","closed_at":null,"author_association":"NONE","body":"<!--\r\nIF YOU DON'T FILL OUT THE FOLLOWING INFORMATION YOUR ISSUE MIGHT BE CLOSED WITHOUT INVESTIGATING\r\n-->\r\n### Bug Report or Feature Request (mark with an `x`)\r\n```\r\n- [*] bug report -> please search issues before submitting\r\n- [ ] feature request\r\n```\r\n\r\n### Area\r\n```\r\n- [ ] devkit\r\n- [*] schematics\r\n```\r\n\r\n### Versions\r\n<!--\r\nOutput from: `node --version` and `npm --version`.\r\n  Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra? High Sierra?)\r\n-->\r\n\r\n\r\n### Repro steps\r\n<!--\r\nSimple steps to reproduce this bug.\r\nPlease include: commands run, packages added, related code changes.\r\nA link to a sample repo would help too.\r\n-->\r\ncall a schematic with an option that is either an object, or null.  Null will cause an error (Cannot convert undefined or null to object), an object will cause all subsequent options to be silently dropped.\r\n\r\nThis is due to the implementation of _deepCopy in schematics/tools/schema-options-transform.ts:\r\n```\r\nfunction _deepCopy<T extends {[key: string]: any}>(object: T): T {\r\n  const copy = {} as T;\r\n  for (const key of Object.keys(object)) {\r\n    if (typeof object[key] == 'object') {\r\n      copy[key] = _deepCopy(object[key]);\r\n      break;\r\n    } else {\r\n        copy[key] = object[key];\r\n    }\r\n  }\r\n\r\n  return copy;\r\n}\r\n```\r\n\r\nThe break causes it to exit early losing any other options, and it doesn't handle null which is also typeof 'object';\r\n \r\n### The log given by the failure\r\n<!-- Normally this include a stack trace and some more information. -->\r\n\r\n\r\n### Desired functionality\r\n<!--\r\nWhat would like to see implemented?\r\nWhat is the usecase?\r\n-->\r\n\r\n\r\n### Mention any other details that might be useful\r\n<!-- Please include a link to the repo if this is related to an OSS project. -->\r\n"}}
{"actor":{"display_login":"james-schwartzkopf"}}