Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$TupleMap unable to handle intersections #7523

Closed
volkanunsal opened this issue Mar 2, 2019 · 2 comments
Closed

$TupleMap unable to handle intersections #7523

volkanunsal opened this issue Mar 2, 2019 · 2 comments

Comments

@volkanunsal
Copy link

volkanunsal commented Mar 2, 2019

Flow version: 0.92

Expected behavior

Expected this to pass:

type Config = {
	layers: {|type: string, options: {foo: number}|}[];
};

type DecoratedConfig =  Config & {
  layers: $TupleMap<
    $PropertyType<Config, 'layers'>,
    <V>() => V & {cartocss_version2: string}
  >,
};
    
var a: DecoratedConfig = {
      layers: [
		  {type: 'sad', options: {}}
	 ]
};

a.layers[0].options.cartocss_version2

Actual behavior

It doesn't pass, and I get this error:

15: var a: DecoratedConfig = {                             ^ Cannot assign object literal to `a` because property `cartocss_version2` is missing in object type [1] but exists in object type [2] in array element of property `layers`.
References:
5: 	layers: {|type: string, options: {foo: number}|}[];
            ^ [1]
11:     <V>() => V & {cartocss_version2: string}                     ^ [2]
21: a.layers[0].options.cartocss_version2                        ^ Cannot get `a.layers[0].options.cartocss_version2` because property `cartocss_version2` is missing in object type [1].
References:
5: 	layers: {|type: string, options: {foo: number}|}[];
                                     ^ [1]

Link

@volkanunsal volkanunsal added the bug label Mar 2, 2019
@goodmind goodmind changed the title TupleMap unable to handle intersections $TupleMap unable to handle intersections Aug 14, 2019
@AuthorityFX
Copy link

I'm running into this issue as well:

const types = useTypes([
                  ^ Cannot call `useTypes` because null or undefined [1] is incompatible with string [2] in index 0 of type argument `Types`. [incompatible-call]
References:
28:   ((Options<T>) => ?$GetType<T>) &
                       ^ [1]
29:   ((OptionsWithDefault<T>) => $GetType<T>)
                                  ^ [2]
type $RetunFn<T> =
  // If both funciton in intersection return the same type,
  // no error when calling useTypes
  // $Call can handle intersection but TupleMap cannot
  // https://github.com/facebook/flow/issues/7523
  ((Options<T>) => ?$GetType<T>) &
  ((OptionsWithDefault<T>) => $GetType<T>)

The intersection of functions work with $Call but not with $TupleMap

https://flow.org/try/#0C4TwDgpgBAKuEGcoF4oG8BQUoHsB2EAXFAsAE4CWeA5gDRZTADuOxeArgLYBGEZ9AXwwZQkKABIA4hGBxIAHhgA+FBICiAGwicIeWfEXwEtWEoDcw0dADyYYBXwJFK1OIBKEAIYATa3g0g8mgAPgxWxDD0wQLmlvBQtvaOAOoUwAAWACIQAGae7BrAzqruXr7+gSEMAHS1iQ54Tsr02N65+YUA-MRSMnIQzlExFiLx9Y4AqngNisSklDQuCXYNTSrBy0mNqRnZeQVFyiNWm6sw7GBaigCMc+RUdLAATHcL1C4MGwDa441TMzBrkoALqfKA-FaTab4G5KEy-BD-GEwJ4g47xUrAdh4ABieGKyAYAHoiVAAJI5KDcHAZKA5bEAYzS+CgVFZej4CAgDK2UDIMnYZDwjHS0AQnh0jHgLSgJKgeBwUD4ZBwZCgTFFwoZng0GgeUHYXP6CGJpPEAGEdRooNrhelPHhvFp2cBOdzedx2MBYBctABZTxgG0OhXAU1QdLAYBgBCEEnUNLpdjcaoMnCcIl5BkQak4ADWmY0OCYRIoCAQ7EQRIA7ABWJ4AZgYAApmwjnABKFAqTq9fQKZRdgBkLbbkO2ib2HUOSi7yBUff6neE9LwPIaBqNBkiDAA+gjiAikfjlBglM2cOPY1B91eOz1Lbr5AwJB4sbiT3C9wiz+hw9rdRdRVAwoEVPG9fksSFJAADcdUrG1VX5BAwHwbx9WARUrAYSDBWFZsOF1YgHRADsLCEUYxEXX0IAANXgiAlwYQEZRRGVby2BBzkuIhTkcbirhY54lCwJZxAEiAAzAZ9sA4s4aJlRQTDkxxDyvY9nHPFTGjnBdHw0eRMWxPFBhvBERNiDBV3XFlDUYowZNgW4SHuGhWJeFy3lYow1M4iSbhMFELObKxr2Ne8JGkWQaPojRKyXIS2NgIwVEwbAclVKBmy0b1QNQAAGMxWSgeQpUgBBqi0GgMiKgBqWqKC7NLsFlUkAOtKhMKgECwIggVoKgOC4ugNMyGQ1DHQwrD4AYIRsFwoUssIjRiLwUjyOENNGm9fBoFQOz+mbZrwigAByXbTsEMiMAvAhiE6eYHmurbSEYFhVAO+AjrCeBiFO5gcEuhg2n2QpiCbARrpClh7o4Hg+GujAXu9UKPq3crmy+Bg0DK3jzoIU6oAEGUcZO-6WEuqAQencGifoYEodCr58uBe7HpoRmjC+a5WflLheDIMigA

@SamChou19815
Copy link
Contributor

The issue seems to fixed a long time ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants