apologies in advance for the claude output - lmk if there's anything else i can provide.
Versions
- Last good:
@typescript/native-preview@7.0.0-dev.20260422.1
- First bad:
@typescript/native-preview@7.0.0-dev.20260423.1
- Stock
tsc 5.x / 6.0 beta: accepts the program
Repro (2 files + 1 dep)
package.json
{
"name": "tsgo-yup-repro",
"private": true,
"dependencies": { "yup": "1.7.1" },
"devDependencies": { "@typescript/native-preview": "7.0.0-dev.20260423.1" }
}
tsconfig.json
{
"compilerOptions": {
"strict": true,
"noEmit": true,
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "Bundler"
},
"include": ["repro.ts"]
}
repro.ts
import * as yup from 'yup';
const schema = yup.object({
name: yup.string().required(),
});
declare function accepts<T extends yup.ObjectSchema<any>>(s: T): void;
accepts(schema);
Run npx tsgo -p tsconfig.json.
Observed (20260423.1)
repro.ts(9,9): error TS2345: Argument of type 'ObjectSchema<{ name: string; }, AnyObject, { name: undefined; }, "">' is not assignable to parameter of type 'ObjectSchema<any, AnyObject, any, "">'.
The types returned by 'optional().strip(...).partial().__outputType' are incompatible between these types.
Type '{ name?: string | undefined; } | undefined' is not assignable to type '{ [x: string]: any; [x: number]: any; [x: symbol]: any; }'.
Type 'undefined' is not assignable to type '{ [x: string]: any; [x: number]: any; [x: symbol]: any; }'.
Exit code 2.
Expected
Clean exit, same as 20260422.1 and stock tsc.
Real-world impact
Breaks every call of @hookform/resolvers/yup's yupResolver, whose signature is <T extends Yup.ObjectSchema<any>>(schema: T, ...). In our codebase: 103 call sites across 40+ files, zero before the bump.
Analysis
The RHS __outputType in the error message resolves to {[x: string]: any; [x: number]: any; [x: symbol]: any} (yup's AnyObject) rather than any. undefined (from optional()) doesn't fit AnyObject, hence the error.
Likely cause: when instantiating ObjectSchema<any> where the type parameter is TIn extends Maybe<AnyObject> (= AnyObject | null | undefined), 20260423.1 resolves the any argument up to its constraint (AnyObject) somewhere along the optional().strip().partial() method chain, where 20260422.1 kept it as any.
apologies in advance for the claude output - lmk if there's anything else i can provide.
Versions
@typescript/native-preview@7.0.0-dev.20260422.1@typescript/native-preview@7.0.0-dev.20260423.1tsc5.x / 6.0 beta: accepts the programRepro (2 files + 1 dep)
package.json{ "name": "tsgo-yup-repro", "private": true, "dependencies": { "yup": "1.7.1" }, "devDependencies": { "@typescript/native-preview": "7.0.0-dev.20260423.1" } }tsconfig.json{ "compilerOptions": { "strict": true, "noEmit": true, "target": "ES2020", "module": "ESNext", "moduleResolution": "Bundler" }, "include": ["repro.ts"] }repro.tsRun
npx tsgo -p tsconfig.json.Observed (20260423.1)
Exit code 2.
Expected
Clean exit, same as
20260422.1and stocktsc.Real-world impact
Breaks every call of
@hookform/resolvers/yup'syupResolver, whose signature is<T extends Yup.ObjectSchema<any>>(schema: T, ...). In our codebase: 103 call sites across 40+ files, zero before the bump.Analysis
The RHS
__outputTypein the error message resolves to{[x: string]: any; [x: number]: any; [x: symbol]: any}(yup'sAnyObject) rather thanany.undefined(fromoptional()) doesn't fitAnyObject, hence the error.Likely cause: when instantiating
ObjectSchema<any>where the type parameter isTIn extends Maybe<AnyObject>(=AnyObject | null | undefined),20260423.1resolves theanyargument up to its constraint (AnyObject) somewhere along theoptional().strip().partial()method chain, where20260422.1kept it asany.