Skip to content
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

Creating class-based guards returns error for functional guard #28839

Open
1 task
squinkyplunky opened this issue Nov 11, 2024 · 1 comment
Open
1 task

Creating class-based guards returns error for functional guard #28839

squinkyplunky opened this issue Nov 11, 2024 · 1 comment

Comments

@squinkyplunky
Copy link

squinkyplunky commented Nov 11, 2024

Command

generate

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

No response

Description

When using ng generate guard, it allows me to select multiple options for class based guards. However when I select multiple options, it returns the following error.

"Can only specify one value for implements when generating a functional guard."

ng generate guard auth 
? Which type of guard would you like to create? CanActivate, CanActivateChild, CanDeactivate
Can only specify one value for implements when generating a functional guard.
ng generate guard auth/auth
? Which type of guard would you like to create? CanActivate
CREATE src/app/auth/auth.guard.spec.ts (478 bytes)
CREATE src/app/auth/auth.guard.ts (133 bytes)

Minimal Reproduction

Create new project guard-bug and try to generate guard auth.

ng new guard-bug
? Which stylesheet format would you like to use? Sass (SCSS)     [ https://sass-lang.com/documentation/syntax#scss                ]
? Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? no
ng generate guard auth
? Which type of guard would you like to create? CanActivate, CanActivateChild, CanDeactivate, CanMatch
Can only specify one value for implements when generating a functional guard.

Exception or Error

Can only specify one value for implements when generating a functional guard.

Your Environment

ng version

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

Angular CLI: 18.2.11
Node: 22.11.0
Package Manager: npm 10.9.0
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1802.11
@angular-devkit/build-angular   18.2.11
@angular-devkit/core            18.2.11
@angular-devkit/schematics      18.2.11
@schematics/angular             18.2.11
rxjs                            7.8.1
typescript                      5.5.4
zone.js                         0.14.10

Anything else relevant?

No response

@geromegrignon
Copy link
Contributor

@dgp1130 As we can't dynamically define prompts, we can't fix it as class-based guards are un-deprecated as far as I understand.

Would you be interested in a PR to include a shorter version of this error in the x-prompt (https://github.com/angular/angular-cli/blob/main/packages/schematics/angular/guard/schema.json#L60) itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants