Skip to content
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

Need to reference the Connect type #101

Closed
jackwlee01 opened this issue Jan 21, 2020 · 4 comments
Closed

Need to reference the Connect type #101

jackwlee01 opened this issue Jan 21, 2020 · 4 comments

Comments

@jackwlee01
Copy link

I need to reference the return type of createConnectedStore, which is Connect. However it seems that I can only import it from the following location:

import { Connect } from 'undux/dist/src/react/createConnectedStore'

This seems a bit odd to me as it would appear that I am importing a type that is only meant to be referenced internally, and perhaps prone to change?

I am using the Connect type to store the return result like so:

let storeConnect:Connect<StoreProps>; // Don't mind the any ;)

Is there a different type I can reference instead. Or are you able to promote the Connect to the 'undux' location?

@bcherny
Copy link
Owner

bcherny commented Jan 21, 2020

Hey there! Are you using Flow or TypeScript? If the latter, you don’t need to explicitly type the return value of createConnectedStore — let TypeScript infer it for you.

@jackwlee01
Copy link
Author

Hey :)

I am using Typescript, but for reasons particular to my app I cannot assign the variable straight away.

My code is a little something like this:

let storeConnect:Connect;

// At some point in the future
storeConnect = createConnectedStore(initial);

@bcherny
Copy link
Owner

bcherny commented Jan 25, 2020

Done in 5.1.0.

I've renamed Connect -> CreateConnectedStore and ConnectAs -> CreateConnectedStoreAs, and exposed both at the top level:

import {createConnectedStore, CreateConnectedStore} from 'undux'

let a: CreateConnectedStore<State> = createConnectedStore(...)

@jackwlee01
Copy link
Author

Awesome, thanks!

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

No branches or pull requests

2 participants