Skip to content

Commit 991cef5

Browse files
committed
Ignore strict type checking for unrecognized flags.
1 parent d079f1e commit 991cef5

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

flag.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ export default class Flag {
7878

7979
get valid () {
8080
const value = this.value
81-
8281
this.#violations = new Set()
8382

8483
if (this.#required) {
@@ -105,16 +104,16 @@ export default class Flag {
105104
if (this.#strictTypes) {
106105
const type = this.type
107106

108-
if (type !== 'any' && type !== '*') {
107+
if (type !== 'any' && type !== '*' && this.recognized) {
109108
if (this.#allowMultipleValues) {
110109
const invalidTypes = value.filter(item => typeof item !== type)
111110

112111
if (invalidTypes.length > 0) {
113-
invalidTypes.forEach(v => this.#violations.add(`"${v}" should be a ${ type }, not ${ typeof v }.`))
112+
invalidTypes.forEach(v => this.#violations.add(`"${this.name}" (${v}) should be a ${ type }, not ${ typeof v }.`))
114113
return false
115114
}
116115
} else if (value !== null && typeof value !== type) {
117-
this.#violations.add(`"${value}" should be a ${ type }, not ${typeof value}.`)
116+
this.#violations.add(`"${this.name}" should be a ${ type }, not ${typeof value}.`)
118117
return false
119118
}
120119
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@author.io/arg",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "An argument parser for CLI applications.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)