angular / angular/angular-cli

[Schematics CLI] Numeric strings in schematics options

Open
#24,360 4 comments 0 reactions 0 assignees View on GitHub
area: @angular-devkit/schematics-cli freq1: low type: bug/fix
Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
14h 23m
Merged PRs (30d)
162

Description

### 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

From http://b/196605664.

Apparently you can't pass in a numeric value into a string argument in schematics. This appears to be interpreted as number and leads to a validation error.

### Minimal Reproduction

```
$ schematics run test --stringValue "1234"
Schematic input does not validate against the Schema: {"stringValue":1234}
Errors:

Data path ".stringValue" should be string.
```

Minimist seems to interpret "1234" as a number instead of a string, and schematics treats that as a type mismatch.

### Exception or Error

_No response_

### Your Environment

```text
See http://b/196605664.
```

### Anything else relevant?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the generate command's option parsing and the minimist handling described in the report, then reproduce the command with --stringValue "1234". Trace where the quoted value becomes a number and verify that numeric-looking values passed to string options reach schema validation as strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.