Behavior difference: tsgo produces different results than TypeScript 6.0.
Steps to reproduce
Repository with minimal code to reproduce the issue: https://github.com/tmadeira/ts7-yup-bug
repro.ts (requires yup@1.6.1):
import { object, string, number, ObjectSchema } from "yup";
import type { AnyObjectSchema } from "yup";
interface MyValues {
foo: string;
bar: number;
}
const specific: ObjectSchema<MyValues> = object({
foo: string().required(),
bar: number().required(),
});
const test: AnyObjectSchema = specific;
tsconfig.json:
{
"compilerOptions": {
"strict": true,
"moduleResolution": "bundler",
"esModuleInterop": true
},
"include": ["repro.ts"]
}
The core issue is in how tsgo evaluates Yup's mapped type Shape:
type Shape<T extends Maybe<AnyObject>, C = any> = {
[field in keyof T]-?: ISchema<T[field], C> | Reference;
};
When T = any, keyof any = string | number | symbol, so Shape<any, any> should structurally satisfy any concrete Shape<MyValues, AnyObject>. tsgo instead treats Shape<any, any> as having no specific keys.
Behavior with typescript@6.0
No errors. tsc 6.0.3 correctly recognizes that ObjectSchema<MyValues> is structurally assignable to AnyObjectSchema (ObjectSchema<any, any, any, any>).
Behavior with tsgo
tsgo 7.0.0-dev.20260624.1 reports TS2322:
repro.ts(14,7): error TS2322: Type 'ObjectSchema<MyValues, AnyObject, any, "">' is not assignable to type 'AnyObjectSchema'.
The types returned by 'optional().concat' are incompatible between these types.
...
Types of parameters 'schema' and 'schema' are incompatible.
Type 'ObjectSchema<any, any, any, any>' is not assignable to type 'ObjectSchema<MyValues | undefined, AnyObject, any, "">'.
The types returned by 'default(...).fields' are incompatible between these types.
Type 'Shape<any, any>' is missing the following properties from type 'Shape<MyValues, AnyObject>': foo, bar
The terminal error — Shape<any, any> is missing properties foo, bar — shows that tsgo does not recognize the mapped type { [field in keyof any]-?: ... } as covering all possible keys.
In our project (yup 1.6.1, strict mode), this produces many errors. The ObjectSchema<ConcreteType> → AnyObjectSchema pattern is pervasive in Yup-based form validation.
Behavior difference: tsgo produces different results than TypeScript 6.0.
Steps to reproduce
Repository with minimal code to reproduce the issue: https://github.com/tmadeira/ts7-yup-bug
repro.ts(requiresyup@1.6.1):tsconfig.json:{ "compilerOptions": { "strict": true, "moduleResolution": "bundler", "esModuleInterop": true }, "include": ["repro.ts"] }The core issue is in how tsgo evaluates Yup's mapped type
Shape:When
T = any,keyof any = string | number | symbol, soShape<any, any>should structurally satisfy any concreteShape<MyValues, AnyObject>. tsgo instead treatsShape<any, any>as having no specific keys.Behavior with
typescript@6.0No errors. tsc 6.0.3 correctly recognizes that
ObjectSchema<MyValues>is structurally assignable toAnyObjectSchema(ObjectSchema<any, any, any, any>).Behavior with
tsgotsgo
7.0.0-dev.20260624.1reports TS2322:The terminal error —
Shape<any, any> is missing properties foo, bar— shows that tsgo does not recognize the mapped type{ [field in keyof any]-?: ... }as covering all possible keys.In our project (yup 1.6.1, strict mode), this produces many errors. The
ObjectSchema<ConcreteType>→AnyObjectSchemapattern is pervasive in Yup-based form validation.