Skip to content

Unable to execute schematics with object configured via angular.json #19492

@bgotink

Description

@bgotink

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, this worked in 11.0.1 / until #18945

Description

It is impossible to start a schematic that has an option of type object where that object comes filled in via the angular.json file.

🔬 Minimal Reproduction

Clone https://github.com/bgotink/angular-cli-repro-19492

Run ng g @repro/schematics:test, get an error.

Comment/delete the default configuration from schematics in angular.json.

Run ng g @repro/schematics:test again, it'll succeed this time.

🔥 Exception or Error

$ ng g @repro/schematics:test
Cannot read property 'constructor' of null

The error is thrown at

const copy = new (Object.getPrototypeOf(valueCasted).constructor)();

🌍 Your Environment



     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 11.0.2
Node: 12.19.0
OS: darwin x64

Angular: 11.0.2
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.2
@angular-devkit/build-angular   0.1100.2
@angular-devkit/core            11.0.2
@angular-devkit/schematics      11.0.2
@schematics/angular             11.0.2
@schematics/update              0.1100.2
rxjs                            6.6.3
typescript                      4.0.5

Anything else relevant?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions