Skip to content

Keeping TS types when wrapping mapState function #606

Closed Answered by posva
agualis asked this question in Help and Questions
Discussion options

You must be logged in to vote

Ah yeah, then

/**
 * @function
 * @template T
 * @param {T} mapper
 */

const mapHelper = (mapper) => useState(useStore, mapper)

You can also create a d.ts where you create the type in TS and then import it:

/** @type {import('./types.d.ts').ExportedType} */
const mapHelper = (mapper) => useState(useStore, mapper)

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@agualis
Comment options

@posva
Comment options

Answer selected by posva
@agualis
Comment options

@posva
Comment options

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