gr2m/javascript-plugin-architecture-with-typescript-definitions

Inherit options types set in `Base.defaults()`

gr2m opened this issue · 3 comments

gr2m commented

Example

const BaseWithDefaults = Base.defaults({ parentOption: "value" })
const baseWithDefaults = new BaseWithDefaults({ childOption: "value" })

baseWithDefaults.options.childOption // should be typed as string
baseWithDefaults.options.parentOption // should be typed as string

I don't know if this is even possible. Any idea?

Here is a playground with the full source code to mess around with

gr2m commented

Here is simpler version of Base with only the static defaults method and a TOptions type parameter: playground. That's how far I got so far

gr2m commented

@jacobwgillespie found a possible solution: playground (via TypeScript's Community Discord)

🎉 This issue has been resolved in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀