Flow: Property missing in object type [1], but exists in object type [2]

Created on 13 Nov 2019  路  2Comments  路  Source: facebook/flow

Flow version: v0.112.0

Expected behavior

No error

Actual behavior

Type error

bug needs triage

All 2 comments

Typescript for comparison: https://www.typescriptlang.org/play/#code/PQKgBAAgZgNg9gdzCYAodAXAngBwKZgCGAxhgK6EwCSAdjmRmALxgDeqYnYxMAlnjQwAuNhy6deAExE0yAWwBGeAE4AaMeLIBnFSNZgpM+UrVgMvOXgBacGnhFaMy3jQDmYAL4bP68Vt4Y9mwG0mCyiiqqZhZ4AF62QY7Obp6oHgDcmLgEeAAe+KR4krT0jCzsXDz8gnre2rqi4hKh4SbeHr4+Yv6BteKGYcYqYh1pmahQZDSkvLZgk9MAFLkieQWBxXQMAJSNYMp45Mo0YLmZXqjEto5gWCIk5JQlDMxsGegLxItY2+lAA

make your expectedInput properties read-only:

/* @flow */
type actualInput = {
    client: {
      id: number,
      user: { id: number, timeZone: string }
    },
    site: { id: number, timezone: string }
};

type expectedInput = {
   +client: {
    +user: {
      +id: number
    },
  },
  +site: {
    +id: number
  },
};

function func(x: expectedInput) {
  return x;
}

const y: actualInput = {};

func(y);

try

Was this page helpful?
0 / 5 - 0 ratings