query icon indicating copy to clipboard operation
query copied to clipboard

fix(query-core): add `number`, `symbol` as safe key for `OmitKeyof` for strictness `safely`

Open manudeli opened this issue 1 year ago • 4 comments

Motivation

TypeScript original Omit's 2nd type parameter's type should be string | number | symbol.

image

But Error is occured when we use OmitKeyof with 'safely' for object having number | symbol key

image

Solution

So I update constraint of OmitKeyof's 2nd type parameter when using 'safely' like original Omit's one

  export type OmitKeyof<
    TObject,
    TKey extends TStrictly extends 'safely'
      ?
          | keyof TObject
          | (string & Record<never, never>)
+         | (number & Record<never, never>)
+         | (symbol & Record<never, never>)
      : keyof TObject,
    TStrictly extends 'strictly' | 'safely' = 'strictly',
  > = Omit<TObject, TKey>

Expectation

No error when we use OmitKeyof with 'safely' for object having number | symbol key

image

manudeli avatar Mar 23 '24 03:03 manudeli

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
query ⬜️ Ignored (Inspect) Visit Preview May 6, 2024 6:19am

vercel[bot] avatar Mar 23 '24 03:03 vercel[bot]

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 7bc46bd2a70213f6665b95da9ee7e02c5acc9802. 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 1 target

Sent with 💌 from NxCloud.

nx-cloud[bot] avatar Mar 23 '24 03:03 nx-cloud[bot]

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 7bc46bd2a70213f6665b95da9ee7e02c5acc9802:

Sandbox Source
@tanstack/query-example-angular-basic Configuration
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-svelte-basic Configuration
@tanstack/query-example-vue-basic Configuration

codesandbox-ci[bot] avatar Mar 23 '24 03:03 codesandbox-ci[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 41.15%. Comparing base (93674fe) to head (0e5199d). Report is 115 commits behind head on main.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7164      +/-   ##
==========================================
- Coverage   41.42%   41.15%   -0.28%     
==========================================
  Files         184      182       -2     
  Lines        7331     7404      +73     
  Branches     1531     1553      +22     
==========================================
+ Hits         3037     3047      +10     
- Misses       3889     3945      +56     
- Partials      405      412       +7     
Components Coverage Δ
@tanstack/angular-query-devtools-experimental ∅ <ø> (∅)
@tanstack/angular-query-experimental 86.69% <87.50%> (+0.23%) :arrow_up:
@tanstack/eslint-plugin-query 85.29% <100.00%> (ø)
@tanstack/query-async-storage-persister 43.85% <100.00%> (-5.35%) :arrow_down:
@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)
@tanstack/query-codemods 0.00% <0.00%> (ø)
@tanstack/query-core 92.94% <92.70%> (-0.32%) :arrow_down:
@tanstack/query-devtools 3.92% <0.00%> (-0.02%) :arrow_down:
@tanstack/query-persist-client-core 57.73% <ø> (ø)
@tanstack/query-sync-storage-persister 82.50% <ø> (ø)
@tanstack/react-query 92.77% <100.00%> (ø)
@tanstack/react-query-devtools 10.71% <ø> (ø)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client 100.00% <ø> (ø)
@tanstack/solid-query 77.74% <ø> (-4.53%) :arrow_down:
@tanstack/solid-query-devtools ∅ <ø> (∅)
@tanstack/solid-query-persist-client 100.00% <ø> (ø)
@tanstack/svelte-query 62.68% <ø> (ø)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client 100.00% <ø> (ø)
@tanstack/vue-query 71.04% <ø> (+0.23%) :arrow_up:
@tanstack/vue-query-devtools ∅ <ø> (∅)

codecov-commenter avatar Apr 02 '24 17:04 codecov-commenter

@TkDodo @tannerlinsley, In my opinion this is quite simple Pull Request, review this please

manudeli avatar May 05 '24 16:05 manudeli