I recently uploaded a typescript definition file for the open source redux-ui-router library to this link, but I am encountering errors with Typescript 1.7.3:
Error TS2656: The exported external package typings file 'C:/.../node_modules/redux-ui-router/index.d.ts' is not recognized as a module. I have reached out to the package author to update the package definition.
Trying to import the library in my typescript files like this:
import ngReduxUiRouter from "redux-ui-router";
As a newcomer to Typescript, I have been searching for a clear explanation of how the definition file should be structured when included in an npm package. There is a helpful wiki entry on typings for npm packages, but it lacks a concrete example to follow.
CORRECTION: I removed the
declare module "redux-ui-router" {
code, and after restarting webpack (which I am using for compilation), everything seemed to function correctly:
export interface ReduxUIRouterAction {
type: string;
payload: any;
}
export interface ReduxUIRouterState {
currentState: Object;
currentParams: Object;
prevState: Object;
prevParams: Object;
}
export function router(state: ReduxUIRouterState, action: ReduxUIRouterAction): ReduxUIRouterState;
export var ngReduxUiRouter: string;
export function stateGo(to: string, params?: Object, options?: Object): ReduxUIRouterAction;
export function stateReload(state: any): ReduxUIRouterAction;
export function stateTransitionTo(to: string, params?: Object, options?: Object): ReduxUIRouterAction;
export default ngReduxUiRouter;
Are these changes aligned with the expectations when incorporating this into an npm package?