react-router-redux icon indicating copy to clipboard operation
react-router-redux copied to clipboard

TypeScript Definitions

Open isman-usoh opened this issue 10 years ago • 7 comments

I really like this library but why aren't you adding no typescript definitions? Typescript is very popular now and I personally am using only libs with definitions provided.

isman-usoh avatar Jan 01 '16 03:01 isman-usoh

Hi @isman-usoh. I don't regularly work with TypeScript, so hadn't thought about adding it. We're very open to PRs, so if you really want this, it would be awesome if you contributed it to the project :) Beware that there's a lot of changes in master right now, so if you do this, be sure to get up-to-date with the latest changes first.

kimjoar avatar Jan 01 '16 14:01 kimjoar

We're stabilized now, I think. So, now's the time to submit a PR!

timdorr avatar Jan 12 '16 17:01 timdorr

Do you plan to start distributing the typings with the package or via the TSD/Typings definition managers?

The typings below cover the 2.0.x version:

declare module ReduxSimpleRouter {
  import R = Redux;
  import H = HistoryModule;

  const UPDATE_LOCATION: string;

  interface HistoryMiddleware extends R.Middleware {
    syncHistoryToStore(store: R.Store, selectRouterState?: Function): void;
    unsubscribe(): void;
  }

  type LocationDescriptorObject = {
    pathname: H.Pathname;
    search: H.QueryString;
    query: H.Query;
    state: H.LocationState;
  };

  type LocationDescriptor = LocationDescriptorObject | H.Path;

  interface RouteActions {
    push(nextLocation: LocationDescriptor): void;
    replace(nextLocation: LocationDescriptor): void;
    go(n: number): void;
    goForward(): void;
    goBack: void;
  }

  function syncHistory(history: H.History): HistoryMiddleware;
  function routeReducer(): R.Reducer;

  const routeActions: RouteActions;
}

declare module "redux-simple-router" {
  export = ReduxSimpleRouter;
}

dimitrikochnev avatar Jan 14 '16 21:01 dimitrikochnev

I think it can live in DefinitelyTyped, but if someone wants to submit it here as a PR, I can take a look at merging it. I'll close this issue and wait for a PR if anyone wants to take it on!

timdorr avatar Jan 14 '16 23:01 timdorr

I'm working on this now whilst adding typescript support to my day job's project. I'm trying to get in the open source habit. Give me a few...

noah79 avatar Jan 17 '16 05:01 noah79

https://github.com/rackt/redux-simple-router/pull/204

noah79 avatar Jan 17 '16 06:01 noah79

FYI ts lint give no-internal-module error on module declaration about. Maybe consider avoiding internal module?

dlebedynskyi avatar Jan 27 '16 16:01 dlebedynskyi