Skip to content

fix inference for generic Types when argument has Default property - #1528

Merged
ssalbdivad merged 3 commits into
arktypeio:mainfrom
Andarist:fix/inference-objects-with-defaults
Nov 10, 2025
Merged

fix inference for generic Types when argument has Default property#1528
ssalbdivad merged 3 commits into
arktypeio:mainfrom
Andarist:fix/inference-objects-with-defaults

Conversation

@Andarist

@Andarist Andarist commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

I'm opening this as an experiment to see what CI has to say about it. It's meant to fix this (TS playground):

import { type, Type } from "arktype"; // types: 2.1.25

function someFunction<TSchema extends Record<string, any>>(
  schema: Type<TSchema, {}>,
): (typeof schema)["infer"] {
  const someData = { hello: "world" };
  return schema.assert(someData);
}

const schema = type({
  hello: type("string").pipe((s) => s === "world"),
  goodbye: "string='blah'",
});

someFunction(schema); // error 😢

I do expect this to break inference related to Standard Schema though.

@github-project-automation github-project-automation Bot moved this to To do in arktypeio Oct 31, 2025
@Andarist
Andarist marked this pull request as draft October 31, 2025 10:58
@Andarist
Andarist marked this pull request as ready for review November 6, 2025 22:20
@ssalbdivad ssalbdivad changed the title Fixed inference for generic Types when argument has Default property fix inference for generic Types when argument has Default property Nov 10, 2025

@ssalbdivad ssalbdivad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing thank you 😍

@ssalbdivad
ssalbdivad merged commit e5eb2ef into arktypeio:main Nov 10, 2025
6 checks passed
@github-project-automation github-project-automation Bot moved this from To do to Done (merged or closed) in arktypeio Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done (merged or closed)

Development

Successfully merging this pull request may close these issues.

2 participants