Fix incorrect types in GameJson.analysis #292
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, I've noticed that the documentation of GameJson.analysis does not quite match what the docs say.
The docs say that in analysis array, an item must have a key 'eval', that is number. Playing around with parsing the responses, I found that the behaviour is different: it seems that there is either 'eval' or 'mate', but never both. This is how I best would express it in Typescript:
I also went into lila source, code, and I believe that the appropriate code is in here, lines 12-35. Now, I am no scala wizard, but I am not certain it actually enforces here that either 'mate' or 'eval' but never both exist, so in my change I have simply removed 'eval' from the required array, and added 'mate' as another optional field.
If preferred, I am happy to implement it in the way to match the typescript description I provided.
Hope this is helpful,
Lukas