FormidableLabs / redux-little-router

A tiny router for Redux that lets the URL do the talking.
MIT License
1.04k stars 113 forks source link

Examples give flow errors, (Flowtypes incorrect?) #268

Closed ZwaarContrast closed 6 years ago

ZwaarContrast commented 6 years ago

Using the example from the README with Flow:

// @flow
import { routerForBrowser } from 'redux-little-router'

const { reducer, middleware, enhancer } = routerForBrowser({
    routes
})

Results in Flow errors:

message: 'object literal (This type is incompatible with the expected param type of BrowserRouterArgs Property `basename` is incompatible:)'
message: 'object literal (This type is incompatible with the expected param type of BrowserRouterArgs Property `historyOptions` is incompatible:)'
message: 'object literal (This type is incompatible with the expected param type of BrowserRouterArgs Property `history` is incompatible:)'

I'm no flow expert, I just starting to use it, but if arguments are truly optional as they seem to be, shouldn't the type for BrowserRouterArgs be:

type BrowserRouterArgs = {
  routes: Object,
  basename?: string,
  historyOptions?: BrowserHistoryOptions,
  history?: History
};

instead of:

type BrowserRouterArgs = {
  routes: Object,
  basename: string,
  historyOptions: BrowserHistoryOptions,
  history: History
};
avogel3 commented 6 years ago

+1, Just started with flow as well, and I've been having this same issue on a fresh project using: