andreypopp / validated

Validate your configurations with precise error messages
91 stars 14 forks source link

Incompatible with Flow 100 #36

Open pronebird opened 4 years ago

pronebird commented 4 years ago
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ node_modules/validated/lib/schema.js.flow:165:14

Cannot return context.unwrap(...) because mixed [1] is incompatible with V [2] in type argument V [3].

 [3]  26│ export type ValidateResult<V> = {
        :
 [1]  58│   unwrap<V>(_validate: (value: mixed) => V): ValidateResult<V> {
        :
     157│
     158│ export class AnyNode<V: mixed> extends Node<$NonMaybeType<V>> {
 [2] 159│   validate(context: Context): ValidateResult<$NonMaybeType<V>> {
     160│     return context.unwrap(value => {
     161│       if (value == null) {
     162│         let repr = value === null ? 'null' : 'undefined';
     163│         throw context.error(`Expected a value but got ${repr}`);
     164│       }
     165│       return value;
     166│     });
     167│   }
     168│ }
     169│

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ node_modules/validated/lib/schema.js.flow:186:23

Cannot coerce JSON.stringify(...) to string because undefined [1] should not be coerced.

     node_modules/validated/lib/schema.js.flow
     183│     return context.unwrap(value => {
     184│       if (!this.eq(value, this.value)) {
     185│         throw context.error(
     186│           `Expected ${JSON.stringify(this.value)} but got ${JSON.stringify(value)}`,
     187│         );
     188│       }
     189│       return (value: any);

     /private/tmp/flow/flowlib_389356b1/core.js
 [1] 509│     ): string | void;

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ node_modules/validated/lib/schema.js.flow:186:61

Cannot coerce JSON.stringify(...) to string because undefined [1] should not be coerced.

     node_modules/validated/lib/schema.js.flow
     183│     return context.unwrap(value => {
     184│       if (!this.eq(value, this.value)) {
     185│         throw context.error(
     186│           `Expected ${JSON.stringify(this.value)} but got ${JSON.stringify(value)}`,
     187│         );
     188│       }
     189│       return (value: any);

     /private/tmp/flow/flowlib_389356b1/core.js
 [1] 509│     ): string | void;

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ node_modules/validated/lib/schema.js.flow:378:81

Cannot coerce repr to string because undefined [1] should not be coerced.

     node_modules/validated/lib/schema.js.flow
     375│       }
     376│       let expectation = this.values.map(v => JSON.stringify(v)).join(', ');
     377│       let repr = JSON.stringify(value);
     378│       throw context.error(`Expected value to be one of ${expectation} but got ${repr}`);
     379│     });
     380│   }
     381│ }

     /private/tmp/flow/flowlib_389356b1/core.js
 [1] 509│     ): string | void;