Skip to content
Source
Sign inSign up
TanStack/form

fix(form-core): fix DeepValue from record values being wrong #1558

OpenLeCarbonator(GitHub profile, opens in a new tab)wants to merge 26 commits intomain fromdeepvalue-records-fixopened

Closes #1551

This PR fixes a wrong intersection that occurs when iterating over template strings (such as records). The issue arose because of TypeScript inferring the following:

type DeepKeysExample = 'records' | `records.${string}` | `records.${string}.name`

type GetValueFrom = 'records.foo.name'
// This matches both `records.${string}.name` as well as `records.${string}`.

// Generated DeepValue: 
// { name: string } & string

// With PR fix:
// string

Important

TypeScript has a limitation with template string types. Nested records are not yet safe. Example below:

type NestedRecord = {
  numberRecord: Record<string, number>
  objectRecord: Record<string, { age: number }>
}

type RecordWrapper = {
  records: Record<string, NestedRecord>
}

type Test1 = DeepValue<RecordWrapper, 'records.foo.numberRecord.bar'>
// Type: NestedRecord & number
// `records.${'foo'}.numberRecord.${'bar'}`
// `records.${'foo.numberRecord.bar'}`

type Test2 = DeepValue<RecordWrapper, 'records.foo.objectRecord.bar'>
// Type: NestedRecord & { age: number }
// `records.${'foo'}.objectRecord.${'bar'}`
// `records.${'foo.objectRecord.bar'}`

type Test3 = DeepValue<RecordWrapper, 'records.foo.objectRecord.bar.age'>
// Type: number
// `records.${'foo'}.objectRecord.${'bar'}.age`
    1. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 83f3c34c4b1880f988a856b9a596e34b4494f5da

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded2m 2sView ↗
      nx run-many --target=build --exclude=examples/**✅ Succeeded35sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-02-24 18:24:23 UTC

    2. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented
      More templates

      @tanstack/angular-form

      npm i https://pkg.pr.new/@tanstack/angular-form@1558

      @tanstack/form-core

      npm i https://pkg.pr.new/@tanstack/form-core@1558

      @tanstack/form-devtools

      npm i https://pkg.pr.new/@tanstack/form-devtools@1558

      @tanstack/lit-form

      npm i https://pkg.pr.new/@tanstack/lit-form@1558

      @tanstack/react-form

      npm i https://pkg.pr.new/@tanstack/react-form@1558

      @tanstack/react-form-devtools

      npm i https://pkg.pr.new/@tanstack/react-form-devtools@1558

      @tanstack/react-form-nextjs

      npm i https://pkg.pr.new/@tanstack/react-form-nextjs@1558

      @tanstack/react-form-remix

      npm i https://pkg.pr.new/@tanstack/react-form-remix@1558

      @tanstack/react-form-start

      npm i https://pkg.pr.new/@tanstack/react-form-start@1558

      @tanstack/solid-form

      npm i https://pkg.pr.new/@tanstack/solid-form@1558

      @tanstack/solid-form-devtools

      npm i https://pkg.pr.new/@tanstack/solid-form-devtools@1558

      @tanstack/svelte-form

      npm i https://pkg.pr.new/@tanstack/svelte-form@1558

      @tanstack/vue-form

      npm i https://pkg.pr.new/@tanstack/vue-form@1558

      commit: 83f3c34

    3. codecov[bot](GitHub profile, opens in a new tab)commented

      Codecov Report

      :white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 89.93%. Comparing base (6892ed0) to head (83f3c34). :warning: Report is 141 commits behind head on main.

      Additional details and impacted files
      @@            Coverage Diff             @@
      ##             main    #1558      +/-   ##
      ==========================================
      - Coverage   90.35%   89.93%   -0.43%     
      ==========================================
        Files          38       49      +11     
        Lines        1752     2006     +254     
        Branches      444      507      +63     
      ==========================================
      + Hits         1583     1804     +221     
      - Misses        149      181      +32     
      - Partials       20       21       +1     

      :umbrella: View full report in Codecov by Sentry. :loudspeaker: Have feedback on the report? Share it here.

      :rocket: New features to boost your workflow:

      • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
      • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
  • thank you for fixing this! is there a timeline on when it will be included in a release? 👀

  • @binajmen Well, the main issue is that this isn't really a fix. This PR has been a bit stale because of that ... but I'm not sure there will be a convenient solution that doesn't need reworking all of the DeepKeys types

  • I made progress! It now shows possible values as union instead of an intersection. Will commit the changes tomorrow.

  • changeset-bot[bot](GitHub profile, opens in a new tab)commented

    🦋 Changeset detected

    Latest commit: 83f3c34c4b1880f988a856b9a596e34b4494f5da

    The changes in this PR will be included in the next version bump.

    This PR includes changesets to release 13 packages
    NameType
    @tanstack/form-corePatch
    @tanstack/react-formPatch
    @tanstack/angular-formPatch
    @tanstack/form-devtoolsPatch
    @tanstack/lit-formPatch
    @tanstack/solid-formPatch
    @tanstack/svelte-formPatch
    @tanstack/vue-formPatch
    @tanstack/react-form-nextjsPatch
    @tanstack/react-form-remixPatch
    @tanstack/react-form-startPatch
    @tanstack/react-form-devtoolsPatch
    @tanstack/solid-form-devtoolsPatch

    Not sure what this means? Click here to learn what changesets are.

    Click here if you're a maintainer who wants to add another changeset to this PR

  • crutchcorn(GitHub profile, opens in a new tab)commented

    it's green! what is blocking the merge?!

    Please don't.

  • Sign in to join this conversation.