Configurable serializer instance; the existing top-level exports become the default instance. No breaking changes.
const api = createSerializer({
strict: true, // default for all classes
formatPropertyName: camelToSnakeCase, // global naming strategy
nullishPolicy: {
undefined: 'remove', // 'keep' | 'remove'
null: 'keep', // 'keep' | 'remove'
},
onTypeMismatch: 'throw', // 'coerce' | 'throw' | 'keep-default'
})strict— global default, overridable per class and per propertyformatPropertyName— global naming strategy, overridable per classnullishPolicy— serialization handling ofundefined/nullvalues; fixes the currentkey: undefinedoutput quirk properlyonTypeMismatch— third error-handling stance alongside throw-fast and collect-all (safeDeserialize):'keep-default'degrades gracefully by keeping the property default and continuing- Options hierarchy: instance → class (
@Serializable) → property (@JsonProperty)
- Enum support:
@JsonProperty({ enum: Color })— membership validation on deserialize,TypeMismatchErrorlisting allowed values serializeToFormData(instance)— multipart/FormData output with dot-notation nesting for file-upload payloads- Reserved scope (~20%) for the first user-filed feature requests
strict: truein tsconfig (improves published.d.tsprecision andSafeResultnarrowing)- Property-based round-trip tests with fast-check:
deserialize(serialize(x))equalsxacross generated shapes
CHANGELOG.md(backfill 2.0.0, maintain going forward)- README "How it compares" section (class-transformer, typescript-json-serializer, ts-serializable, zod)
- Resolve js-yaml Dependabot alert
- Follow-up comments on closed issues #6-#9
- JSON Schema generation from decorator metadata (
toJsonSchema(Track)) — single source of truth for parsing and API contracts - Zero-dependency build: vendor lodash
get/setwith ported test vectors - Configurable date format handling
preserveModulesdist layout
- Serialization groups/views and class-to-class transformation (class-transformer territory; conflicts with the API-adapter focus)