-
Notifications
You must be signed in to change notification settings - Fork 630
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
fix(encoding/toml): serializes mixed array #1001
Conversation
I think your unit tests fail to account for the fact that object keys aren't necessarily ordered :) (also make sure you run |
encoding/toml.ts
Outdated
class Dumper { | ||
maxPad = 0; | ||
srcObject: Record<string, unknown>; | ||
output: string[] = []; | ||
_arrayTypeCache = new Map<unknown[], ArrayType>(); |
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 suggest to use private field (prefixed with #
instead of _
)
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 you think we should update methods starting with _
too? Maybe for the whole project?
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 think we should use #
for methods too (at least for Dumper class).
encoding/toml_test.ts
Outdated
mixedArray1: [1, { b: 2 }], | ||
mixedArray2: [{ b: 2 }, 1], | ||
nestedArray1: [[{ b: 1 }]], | ||
nestedArray2: [[[{ b: 1 }]]], | ||
deepNested: { | ||
a: { | ||
b: [1, { c: 2, d: [{ e: 3 }, true] }], | ||
}, | ||
}, | ||
}; |
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.
Make sure that this test exercises all variants from ArrayType
enum
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.
LGTM
fixes #983
Previously, arrays are assumed to be homogenous, but that is not the case (or it is changed recently?).
https://github.com/toml-lang/toml/blob/master/toml.md#user-content-array