andreypopp / validated

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

Does not work with latest version of flow #29

Closed Alxandr closed 5 years ago

Alxandr commented 6 years ago

I get

Missing type annotation for `$NonMaybeType`.

from the AnyNode class. I'm not sure how best to fix this :-/.

LoganBarnett commented 6 years ago

Looks like there's some problems with $NonMaybeType and polymorphic types: https://github.com/facebook/flow/issues/2236

Alxandr commented 6 years ago

You linked to a year old issue for something that just started happening?

tmowad commented 6 years ago

I see what Alxandr sees. More context added in case it helps. This is with flow-bin 0.71.0.

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ node_modules/validated/lib/schema.js.flow:158:45

Missing type annotation for $NonMaybeType.

     155│   }
     156│ }
     157│
     158│ export class AnyNode<V: mixed> extends Node<$NonMaybeType<V>> {
     159│   validate(context: Context): ValidateResult<$NonMaybeType<V>> {
     160│     return context.unwrap(value => {
     161│       if (value == null) {

Found 1 error
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Both with validated 1.1.3 and the latest 1.2.0.

LoganBarnett commented 6 years ago

@Alxandr I don't know why this is new for this library, but yes the issue I linked is indeed still open. It has something to do with a recent version of Flow. Downgrading has been our approach (we're on 0.64 and everything works presently). We tried the upgrade and got this failure. I did some research and the linked ticket is the closest thing I could find to it. Perhaps it's a regression?

FWIW I didn't make the connection that @andreypopp had been participating on the ticket until after I'd linked it. I'd like to keep my participation here productive - If there's a better way for me to signal "I'm having this issue too, and this is what I was able to find relating to it", please let me know. Thanks!

Alxandr commented 6 years ago

The type itself does not produce any error though. For instance, the following works:

// @flow

function test<T: mixed>(v: $NonMaybeType<T>): $NonMaybeType<T> {
  return v;
}

class Foo<T> {}

class Bar<T: mixed> extends Foo<$NonMaybeType<T>> {}

(tryflow)

forticulous commented 6 years ago

In case anyone is interested, it looks like this error occurs in 0.70 and up, 0.69 does not have this issue

Alxandr commented 6 years ago

Anyone managed to figure out what is causing this issue? I don't see anything in the changelog for 0.70 that should cause this to change.

pronebird commented 5 years ago

Closed by #30. Can others confirm? @LoganBarnett

caoilte commented 5 years ago

@pronebird upgrading to Flow 0.77.0 and Validated 1.3.0 fixed the type errors in Validated that were stopping me from upgrading beyond Flow 0.69.0 with Validated 1.2.0.

LGTM