Skip to content

@angular/cli accepts component name starting with numerical character which is not supported as class name #28548

@harshlakhara

Description

@harshlakhara

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

So I wanted to create a component for 404 page and ran the command ng g c 404 it created the component but the component immediately thrown error for component class name. I think we can fix this issue by having regex to validate the component name or atleast we can show info to user to not create component name starting with numbers. Here is the reproduction for the error:

Here

image

Minimal Reproduction

  1. Run ng g c 404 in your angular project.
  2. Open the component which will have compilation error being thrown.

Exception or Error

No response

Your Environment

Angular CLI: 18.2.6
Node: 18.20.3
Package Manager: npm 10.2.3
OS: linux x64

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

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

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions