facebook / flow

Adds static typing to JavaScript to improve developer productivity and code quality.
https://flow.org/
MIT License
22.09k stars 1.86k forks source link

Flow get-def not returning correct information. #3761

Open Morphexe opened 7 years ago

Morphexe commented 7 years ago

I have this in my .flowconfig:

module.name_mapper='^STUB' -> '<PROJECT_ROOT>/src/redux/action/auth'

And I am using in another file:

import {ClassA,ClassB } from 'STUB'

If i do a get-def in either ClassA or ClassB (char 10, line 2), I get:

{"path":"","line":0,"endline":0,"start":1,"end":0}

If I do it in the STUB (char 36, line 2) part I get the correct file and definition:

{"path":"E:\\Desktop\\React Gesp Final\\src\\redux\\action\\auth.js","line":0,"endline":0,"start":1,"end":0}

Am I missing something? Both ClassA and ClassB are Es6 classes exported from the file in question, the code works in production.

Shouldnt FLOW point to the actualy location of ClassA and ClassB on the auth.js file?

This is using the CLI directly after booting the server.

Morphexe commented 7 years ago

Ok , so this seems to be related to a export in the offending module.

if I export the reducer without the : any annotation, all the export from this module seem to not work


 export const reducer : any = handleActions(
  {
    [LoggedOut]: (state, action) => ({
      ...state,
      auth: null,
    }),
    [LoggedIn]: (state, action) => ({
      ...state,
      auth: false,
    }),
    [LoginToggle]: (state, action) => ({
      ...state,
      loginVisible: action.payload,
    }),
  },
  {auth: null, loginVisible: false},
 );

Just wondering is this the desired behaviour or is there something else that I missed? For now I am exporting the reducers as any, it seems to solve the issue.