bcherny / undux

⚡️ Dead simple state for React. Now with Hooks support.

Home Page:https://undux.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Need to reference the Connect type

jackwlee01 opened this issue · comments

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?

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.

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);

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(...)

Awesome, thanks!