superstruct icon indicating copy to clipboard operation
superstruct copied to clipboard

Mask fails on `interface aaa { foo: string; [key: string]: any }` interface with any key.

Open oleg-slapdash opened this issue 2 years ago • 0 comments

This code throws an error, while this is a valid typescript code:

const interfaceWithAKnownKey = intersection([
  record(string(), any()),
  object({
    foo: string(),
  }),
]);

// Typescript: No ERROR.
const test: typeof interfaceWithAKnownKey.TYPE = {
  foo: "bar",
  extra: "buzz",
};

// StructError: At path: extra -- Expected a value of type `never`, but received: `"buzz"`
interfaceWithAKnownKey.mask(test);

oleg-slapdash avatar Jan 09 '24 18:01 oleg-slapdash