-
Notifications
You must be signed in to change notification settings - Fork 196
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
feat(store): add experimental config resolve helper #1826
Conversation
alvrs
commented
Oct 25, 2023
•
edited
Loading
edited
- Aims to solve one of the main pain points of our current config parser, which breaks on user types in some cases
- Note that this is just a temporary solution, we're still planning to refactor our config parsing from ground up in the medium term (see prototype new MUD config #1668 for context)
🦋 Changeset detectedLatest commit: 5295bb2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
mudConfig({ | ||
// Seems like we need `as const` here to keep the strong type. | ||
// Note it resolves to the strong `""` type if no namespace is provided. | ||
// TODO: require the entire input config to be `const` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember trying to add as const
to our default MUD configs (world config, store config) and it broke downstream types in weird ways. Hopefully we can just add this more specific as const
to just the namespace without those downstream effects, but yeah, should aim to as const
the whole config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah the arrays for e.g. enums
currently complain if the whole config is as const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we wanna add as const
to the world/store namespaces here?
} | ||
|
||
return { | ||
...config, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this function isn't being called by default as part of mudConfig
, we could just not include config
here since we'd have a reference to it already being part of the input and only return the resolved
config (and then no need to worry about naming of _resolved
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, updated
.changeset/dirty-cows-lie.md
Outdated
--- | ||
|
||
Added an experimental `resolveConfig` helper to refine the output type of `mudConfig` and simplify downstream consumption. | ||
Note that it's not recommended to use this helper externally yet, since the format is expected to change soon while we're refactoring the config parsing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is internal/not recommended for external use, we could just not document this? 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a changeset to trigger a snapshot release, but since we also added mapObject
here there will be a snapshot release anyway, so happy to remove this one
Co-authored-by: Kevin Ingersoll <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏 thank youuuuu