7

I recently added a typescript definition file for the open source redux-ui-router library, but I'm now getting errors like the following with Typescript 1.7.3:

error TS2656: Exported external package typings file 'C:/.../node_modules/redux-ui-router/index.d.ts' is not a module. Please contact the package author to update the package definition.

I am trying to import this library with code like this in my typescript files:

import ngReduxUiRouter from "redux-ui-router";

I'm new to Typescript, and I can't find a clear description of what exactly this definition file should look like when included with an npm package. There's a wiki entry that talks about typings for npm packages, but outside of repeating the direction that an external module should be used, there's not a concrete example to work from.

CORRECTION I've tried removing the declare module "redux-ui-router" { code, and that seemed to work after restarting webpack, which I'm using to compile everything (I removed the comments for brevity):

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;

Is this set of changes what would be expected when including this in an npm package?

1 Answer 1

4

Is this set of changes what would be expected when including this in an npm package?

Yes. The exports need to be root level at the file.

In other words : an ambient file is not an external module

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.