glenjamin / transit-immutable-js

Transit serialisation for Immutable.js
MIT License
250 stars 31 forks source link

undefined becomes null when serializing #48

Open lukas1994 opened 4 years ago

lukas1994 commented 4 years ago
interface IEditorModel {
  timeDimension?: TimeDimension;
}
const defaultEditorModel: IEditorModel = {
  timeDimension: undefined,
};

export class EditorModel extends Record(defaultEditorModel, "EditorModel") implements IEditorModel {
  public constructor(values?: Partial<IEditorModel>) {
    super(values);
  }
}
const em = new EditorModel();
expect(em.timeDimension).toBeUndefined();
console.log(recordTransit.toJSON(em));

This code serializes timeDimension to null even though the first expect passes. Any ideas why this is happening?

lukas1994 commented 4 years ago

repro: https://codesandbox.io/s/immutablejs-t910c