doc: update Deviation's key (string) → path (array)#19
Conversation
| type Deviations = Iterator< | ||
| string, // "foo['bar-qux']['zed']" | ||
| (number | string | Symbol)[], // ['foo', 1, Symbol('zed')] | ||
| { |
There was a problem hiding this comment.
TypeScript defines the parameters of Iterator as <T, TReturn = any, TNext = any>, so this is expressing an iterator that always yields an array of primitives and returns an { actual, expected, reason } object. I think we actually want IterableIterator<Deviation>, where Deviation is { path, actual, expected, … } as in #15.
| Iterator => Iterable(2) { | ||
| "foo['bar']" => { | ||
| ['foo', 'bar'] => { |
There was a problem hiding this comment.
Concretely, what are the fat arrows in Iterable(2) { ['foo', 'bar'] => {…}, ['foo', 'bar', 'qux'] => {…} } expressing? Are you envisioning each iteration result being a two-element array in which the first element [path] is itself an array? That seems less useful to me than having the result be a Deviation object with a property named "path".
There was a problem hiding this comment.
The fat-arrow is just how V8 represents a key-value pair in a Map. Since this is Map-like and I couldn't find a better example for a generic Iterator, I copied the Map representation.
This was a change we decided on a long time ago; it somehow got missed in all the updates since.