Skip to content
Source
Sign inSign up
TanStack/virtual

fix(virtual-core): add bigint to Key to align with @types/react implementation #814

Mergedhuv1k(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/814/headmerged by piecyk

This PR enhances Key type with bigint to align with React.Key. This was updated in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/66723. This will enable us to use React.Key as type for where we require Key as type.

    1. If changed like that, it might be more convenient when using React.

      However, Should the higher-level element 'core' depend on the lower-level element 'react'? How about using type casting in React?

      const alsoHuge = BigInt(9007199254740991);
      
      alsoHuge.toString();
    2. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      ☁️ Nx Cloud Report

      CI is running/has finished running commands for commit 892a4d54e8467bb41feee620426f759c2de19bdb. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

      📂 See all runs for this CI Pipeline Execution


      ✅ Successfully ran 2 targets

    3. Sent with 💌 from NxCloud.

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

    commit: 892a4d5

    @tanstack/angular-virtual

    pnpm add https://pkg.pr.new/@tanstack/angular-virtual@814

    @tanstack/lit-virtual

    pnpm add https://pkg.pr.new/@tanstack/lit-virtual@814

    @tanstack/react-virtual

    pnpm add https://pkg.pr.new/@tanstack/react-virtual@814

    @tanstack/solid-virtual

    pnpm add https://pkg.pr.new/@tanstack/solid-virtual@814

    @tanstack/svelte-virtual

    pnpm add https://pkg.pr.new/@tanstack/svelte-virtual@814

    @tanstack/virtual-core

    pnpm add https://pkg.pr.new/@tanstack/virtual-core@814

    @tanstack/vue-virtual

    pnpm add https://pkg.pr.new/@tanstack/vue-virtual@814

    Open in Stackblitz

    More templates

  • However, Should the higher-level element 'core' depend on the lower-level element 'react'?

    @SaeWooKKang allowing bigint as key is not really connected to react

  • Yes, the problem is when you use Key from react, because it has a different type and there is an error, which shouldn't be the case. Is there anything more needed?

  • @SaeWooKKang allowing bigint as key is not really connected to react

    You're right, there isn't a direct connection. However, my comment was about whether it's appropriate to add a type to the key specifically for the purpose of using it with React.

    Yes, the problem is when you use Key from react, because it has a different type and there is an error, which shouldn't be the case. Is there anything more needed?

    Is there no need to modify the documentation for the type?

  • However, my comment was about whether it's appropriate to add a type to the key specifically for the purpose of using it with React.

    Yep, thanks for the input. I think we are fine here, as bigint is overall an primitive not a react thing.

    Is there no need to modify the documentation for the type?

    good catch, @huv1k can you update docs at https://github.com/TanStack/virtual/blob/main/docs/api/virtual-item.md

  • However, my comment was about whether it's appropriate to add a type to the key specifically for the purpose of using it with React.

    Yep, thanks for the input. I think we are fine here, as bigint is overall an primitive not a react thing.

    Is there no need to modify the documentation for the type?

    good catch, @huv1k can you update docs at https://github.com/TanStack/virtual/blob/main/docs/api/virtual-item.md

    Updated 🙌

  • piecyk merged this1e12f81

  • piecyk closed this

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

    Why not just use the React type for keys?

  • Why not just use the React type for keys?

    As core should not be bound to any lib, adding the bigint created other issues like #819

  • Why not just use the React type for keys?

    As core should not be bound to any lib, adding the bigint created other issues like #819

    Fair enough, I forgot that the core can be used across different frameworks

  • Sign in to join this conversation.