ianstormtaylor / superstruct

A simple and composable way to validate data in JavaScript (and TypeScript).

Home Page:https://docs.superstructjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

oleg-slapdash opened this issue · 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);