简体   繁体   中英

Flow Abstract Type and Function - Property cannot be accessed

I'm using flow with react native and I must be missing something.

I tried to express my issue with words but there's no way it doesn't get really confusing so here is the situation: Flow Try

I've been fiddling around this for a while but couldn't quite figure out why can't I use the property that I defined!

Any help would be gratefully received.

I'd probably write the code as either

type Subscriber<P> = (params: P) => boolean;

type ParkSelectedEventParams = {
    park_selected: {}
};

let onParkSelected: Subscriber<ParkSelectedEventParams> = (params: ParkSelectedEventParams): boolean => {
      console.log(params.park_selected);
      return true;
};

( On Flow Play )

or I believe you can trim down the last part to

let onParkSelected: Subscriber<*> = (params: ParkSelectedEventParams): boolean => {
      console.log(params.park_selected);
      return true;
};

since the function declaration part allows Flow to know how to fill in the * .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM