Replies: 1 comment
-
Implementation of the check which probably could work: if (__DEV__) {
function getIndexIds(i: IndexWidget): string[] {
return i
.getWidgets()
.filter(isIndexWidget)
.reduce<string[]>(
(acc, curr) => [...acc, ...getIndexIds(curr)],
[i.getIndexId()]
);
}
const indexIds = Object.keys(initialUiState);
const expectedIndexIds = getIndexIds(this.mainIndex);
if (indexIds.every((id) => expectedIndexIds.indexOf(id) === -1)) {
console.log('warning');
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is your feature request related to a problem? Please describe 🙏
Giving this does not give a warning at all, while it should.
(the correct code is:)
Describe the solution you'd like 🤔 A clear and concise description of what you want to happen.
A warning somewhat like this should be thrown:
Describe alternatives you've considered ✨ A clear and concise description of any alternative solutions or features you've considered.
I was thinking we could warn if the value of a root UiState is not an object, but that would fail with most widgets (hierarchical, refinement, menu ...) which have a key per attribute.
We could also whitelist based on known keys of widgets, however that isn't technically an error on their part, but probably the closes
We can also warn when none of the keys are a registered index (i.e. either root index name, or its child widgets (recursive)). This needs to happen at the init step probably.
I don't see how to put this in the existing warning, since that's on a per-index level, so we'd need to warn as well if nothing has initialUiState, but there was a non-empty initialUiState.
we can also warn if there are multiple keys, and the root index is missing, but that could be a false positive if there are other index widgets.
Beta Was this translation helpful? Give feedback.
All reactions