facebookarchive / ide-flowtype

Flow support for Atom IDE
Other
178 stars 17 forks source link

Not Showing Correct Type #27

Closed bradennapier closed 6 years ago

bradennapier commented 6 years ago

I have the following type for displaying a notification:

type NotificationParams = {|
  uid?: number | string,
  title: string,
  message: string,
  level?: 'info' | 'warning' | 'success' | 'error',
  position?: 'tr' | 'tl' | 'tc' | 'br' | 'bl' | 'bc',
  autoDismiss?: number,
  dismissable?: boolean,
  action?: NotificationAction,
  children?: any,
  sfx?: string,
  say?: string,
  onAdd?: (notification: NotificationParams) => void,
  onRemove?: (notification: NotificationParams) => void
|};

type NotifyUserAction = {|
  type: 'NOTIFY_USER',
  params: NotificationParams,
  sfx?: string,
  say?: string
|};

export default function* notifyUser(params: NotificationParams): Generator<*, *, *> {
  const notificationAction: NotifyUserAction = {
    type: 'NOTIFY_USER',
    params,
  };
  yield put(notificationAction);
}

When I add the file that is used to create the notification which is annotated, I only get some of the values from the type.

image

hansonw commented 6 years ago

ide-flowtype (and the underlying flow-language-server) shell out to the command-line flow type-at-pos command. This feels like a bug with Flow itself.

Could you try flow type-at-pos <filename> <line> <col> --json to see what the raw output is? If it's the same as what Atom displays please file an issue over at https://github.com/facebook/flow instead.

bradennapier commented 6 years ago

Ok got that to work

{"type":"{action?: {|callback: () => void, label: string|}, autoDismiss?: number, children?: any, dismissable?: boolean, level?: 'error' | 'info' | 'success' | 'warning', onAdd?: (notification: any) => void, onRemove?: (notification: any) => void, position?: 'bc' | 'bl' | 'br' | 'tc' | 'tl' | 'tr', say?: string, sfx?: string, uid?: number | string}","reasons":[],"loc":{"source":"/Users/bradennapier/Desktop/Dash OS/IDE/projects/dash-desktop/app/shared/processes/dash/console/console.js","type":"SourceFile","start":{"line":375,"column":27,"offset":10864},"end":{"line":380,"column":9,"offset":10994}},"path":"/Users/bradennapier/Desktop/Dash OS/IDE/projects/dash-desktop/app/shared/processes/dash/console/console.js","line":375,"endline":380,"start":27,"end":9}

Will report it to flow