Skip to content

Custom builders: Can no longer use an option called "target" with "enum" restriction #24511

Open
@fischeversenker

Description

@fischeversenker

Command

other

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

13.3.9

Description

When writing custom Angular builders I was able to specify a builder option with the name target that used the enum property in the builder's schema.json file. Starting with Angular 14 this changed. Now, I can still specify an option with this name in my builder's schema, but it must not have an enum property. Otherwise, the builder fails in what seems to be the yargs validation in the angular-cli's command-runner. Note that there is also other unexpected behavior when using a type of boolean for the target option, which throws a seemingly unrelated error.

I wasn't able to find anything regarding this in the changelog of angular or angular-cli, so it seems like it's an accidental breaking change. Instead of renaming the option in our builder(s), we figured out that it's enough to just remove the enum property from the schema.json, but eventually, it would be nice to be able to use enum again.

Minimal Reproduction

I prepared a reproduction repository here. Follow the "Quick start" section in the README.md file to reproduce the error locally.

Exception or Error

No response

Your Environment

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

Angular CLI: 14.2.10
Node: 18.12.1 (Unsupported)
Package Manager: npm 8.19.2 
OS: linux x64

Angular: 14.2.12
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.10
@angular-devkit/build-angular   14.2.10
@angular-devkit/core            14.2.10
@angular-devkit/schematics      14.2.10
@angular/cli                    14.2.10
@schematics/angular             14.2.10
rxjs                            7.5.7
typescript                      4.7.4

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions