I am using io-ts to build a simple record codec:
import * as t from "io-ts";
const myRecordCodec = t.record(t.string, t.string);
I think this is equivalent to the following type:
type MyRecord = Record<string, string>;
I test it as follows:
describe("myRecordCodec", () => {
it("returns true for record", () => {
expect(myRecordCodec.is({ a: "Oh hai, Mark!" })).toBe(true);
});
it("returns false for date", () => {
const myDate = new Date();
expect(myRecordCodec.is(myDate)).toBe(false);
});
});
I’m surprised to find that the second test fails.
Is this expected? Am I using record
correctly?