(value: any)
| 29 | } |
| 30 | |
| 31 | coerce(value: any) { |
| 32 | // First find instances |
| 33 | for (const type of this.itemTypes) { |
| 34 | if (type.isInstance(value)) { |
| 35 | return type.coerce(value); |
| 36 | } |
| 37 | } |
| 38 | // Try coercible |
| 39 | for (const type of this.itemTypes) { |
| 40 | if (type.isCoercible(value)) { |
| 41 | return type.coerce(value); |
| 42 | } |
| 43 | } |
| 44 | const msg = util.format('Invalid %s: %j', this.name, value); |
| 45 | throw new TypeError(msg); |
| 46 | } |
| 47 | |
| 48 | serialize(value: any) { |
| 49 | for (const type of this.itemTypes) { |
nothing calls this directly
no test coverage detected