facebook / facebook/flow

import star as does not work

Aperta
#3,732 1 commento 5 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
22.3k
Fork
1.9k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi guys,

Mark it as duplicate if it is, but there is an issue with computing `import * as NAME from '[PATH]'`.

Here is an example:

`Jobs$Action` and `Jobs$Jobs` defined in flow-typed folder.

`Jobs$Action` code looks like that:

```js
// Ui
declare type Jobs$ShowCreateJobAction = { +type: actionTypes.SHOW_CREATE_JOB };
declare type Jobs$HideCreateJobAction = { +type: actionTypes.HIDE_CREATE_JOB };

// Jobs
declare type Jobs$FetchJobsSuccessAction = { +type: actionTypes.FETCH_JOBS_SUCCESS, +jobs: Jobs$Jobs };
declare type Jobs$FetchJobsRequestAction = { +type: actionTypes.FETCH_JOBS_REQUEST };

// errors
declare type Jobs$FetchFailAction = { +type: actionTypes.FETCH_FAIL, +error: Error };

declare type Jobs$Action =
| Jobs$FetchJobsRequestAction
| Jobs$FetchJobsSuccessAction
| Jobs$ShowCreateJobAction
| Jobs$HideCreateJobAction
| Jobs$FetchFailAction;
```

Reducer, which uses this action:

```js
// @flow

import * as types from "app/constants/action-types";

const InitialState = [];

export default function (state: Jobs$Jobs = InitialState, action: Jobs$Action) {
switch (action.type) {
case types.FETCH_JOBS_SUCCESS:
return [
...action.jobs
];

default:
return state;
}
}

```

Error is:
`Error:(11, 27) Flow: property 'jobs'. Property not found in object type `

More precise is:
```
11: action.error
^ property `error`. Property not found in
11: action.error
^ object type
```

So if I change the `types.FETCH_JOBS_SUCCESS` to `'FETCH_JOBS_SUCCESS'` it will work:

```js
// @flow

import * as types from "app/constants/action-types";

const InitialState = [];

export default function (state: Jobs$Jobs = InitialState, action: Jobs$Action) {
switch (action.type) {
case 'FETCH_JOBS_SUCCESS':
return [
...action.jobs
];
default:
return state;
}
}

```

Here is isolated replication of the issue:

https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVBLAtgBzgJwBdkwBDAZzEIE8cBTSqfOLMAIlJx2AGM4A7coVL9C5YKR6EMAgLQ165NgG50AEzo8YpfHSq09AKTgAjcgBJjZsAF4wAbzD9SWOgC4wQ-Bn4BzMAC+qqjAwGAAqhioGlo6egpGphYAygAWiADCuqSEdFYAglIy-LYOYADUCR4A5AASAKIAMo0A8tWBqjHauvr0YFYWtRgaWXQ5eaaF0gKljpUGNQ3NLQBM7UHoIWED0Zrd8Qb9SeYAYnSEPKkDyQCuPDwM5FPFsxVVYHVNrQDM1QA0FQAVkkPANLEkOrtYj0EkczKdzpcBgAlOgARxuDEIzxmdjm70+ywALOtgqEwHR8Mx8OQofteol4WcLqkTqQMDAcSU8W8FgzyAA6E71AAqGVqAH0TvkAJKNAHlSnUjz1KkESF0uIMuEWLmlMHMpFJVEYrF6gA+OoRLOudwe5CeRRmlrBaUy2VyBSdJRdxyGIw9ExMFqthtZ7M53uCXS1sLBABEMOQcDlLqUABSSab8UHHENgkWpG78ADW+eOAAVmFgk3QuQBKWwAPjI-GonT2scOYIA4udksJchnGzYWy0TIDNIQO9CDn0C0XS3q7Om1EmUyzc-DE8nU6kAb5+4P3Fa+4QB+MRy2RO3NTDu5Xq7Xl2AqyxawAeMFcpvBWEXoc8VQMAQLAKBEVSVVqXIDx8ipUhqA-KCCCbVANlQPhBGIGV+AwaRSBgAC9CA0CwIg5CaQ8ABtABdNDgjoAAPPAiDADQoFIG4YGIKBi29dMhHGDwiNKHC8IwAiiIBLNii3XVvUbexgNA8gEDwtNM29AUEkU5TSJAngKDnBghVFcUpVlRo3D0-TSN0QgbnwEolNs1zQIFDzBNyP4bLc0jwJZCiYLAKjfL82yPIFLy6AFALLiCnzwvCmSBAFJUCDC8K6KSyE3PYzjuOsnL7MckpotUUiAjQoA

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.