Skip to content

Inherit options types set in Base.defaults() #32

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

Closed
gr2m opened this issue Apr 1, 2021 · 3 comments · Fixed by #33
Closed

Inherit options types set in Base.defaults() #32

gr2m opened this issue Apr 1, 2021 · 3 comments · Fixed by #33
Labels

Comments

@gr2m
Copy link
Owner

gr2m commented Apr 1, 2021

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
Copy link
Owner Author

gr2m commented Apr 5, 2021

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
Copy link
Owner Author

gr2m commented Apr 6, 2021

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

@github-actions
Copy link

github-actions bot commented Apr 6, 2021

🎉 This issue has been resolved in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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