Skip to content

Fix typings in packaged index.d.ts #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

dballance
Copy link
Contributor

Convert typescript typings to an external module.

Resolves #44

Convert typescript typings to an external module.
@wbuchwalter
Copy link
Member

Hey Drew,
Thanks for the PR, looks good except one thing:

export var ngRedux: string;
export default ngRedux; 

Here you are just exporting a plain old string as default value. So this is probably not what you wanted to do.

Before we had:

declare module "ngRedux" {      
   export = ngRedux;        
}

this was the old internal module syntax, and it allowed you yo directly access all the interfaces like so:

var myVar: ngRedux.Middleware;

With the new external module syntax, the equivalent would be:

import * as ngRedux from 'ng-redux';

So you can remove the two last lines.
Thanks.

@dballance
Copy link
Contributor Author

That's an intentional export to match what is exported from the module and to allow direct address of the angular module string.

With the current structure of index.d.ts in this pull request, you can address ng-redux as below.

import * as ngRedux from 'ng-redux';
import { rootReducer } from "./reducers/index";

angular.module('app', [ngRedux.default])
.config(($ngReduxProvider: ngRedux.INgReduxProvider) => {
    $ngReduxProvider.createStoreWith(rootReducer);
  });

The default export closely matches what is exported by the module and allows direct address of the interfaces. I used this pattern in a sample I was building (mostly to learn redux myself) and the above pattern worked for me.

Can see this sample here and it matches up to the PR mention in #44 with redux-ui-router. Does this achieve what you wanted?

@wbuchwalter
Copy link
Member

👍
Didn't thought about that, you're right.
Thanks!

wbuchwalter added a commit that referenced this pull request Dec 11, 2015
@wbuchwalter wbuchwalter merged commit 8d298e5 into angular-redux:master Dec 11, 2015
@dballance
Copy link
Contributor Author

👍

Glad I could help!

@wbuchwalter
Copy link
Member

I won't be able to release the npm package today, so will do that tomorrow. Sorry for the delay!

@mwilc0x
Copy link

mwilc0x commented Dec 11, 2015

awesome, thank you @dballance && @wbuchwalter! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants