The type definition for OpenAPIV3_1.SchemaObject is:
export type SchemaObject = (ArraySchemaObject | NonArraySchemaObject | MixedSchemaObject | boolean) & AnyOtherAttribute;
The problem is that the schema might be a boolean according to this type, and the intersection with AnyOtherAttribute is distributed across the union. The consequence of this is that TypeScript treats the boolean possibility as potentially having unknown attributes of any type. In my opinion, boolean & AnyOtherAttribute doesn't make sense as a type, and should perhaps be considered a bug in the library.
If you narrow the type of schemas.foo to eliminate the boolean possibility, the type of discriminator is as expected:
import type { OpenAPIV3_1 } from "@scalar/openapi-types";
const schemas: Record<string, OpenAPIV3_1.SchemaObject> = {};
if (typeof schemas.foo === "object") {
schemas.foo.discriminator;
}
(property) discriminator?: OpenAPIV3.DiscriminatorObject | undefined

anyis a known problem. It is not related to a known or unknown type, it is related to the object itself. To work around 1) Add a variable/property to the WATCH list under the Run and Debug container element, 2) Enter it in the Debug Console input line.