Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-key get typings overload #359

Merged
merged 3 commits into from
Jun 14, 2022

Conversation

trevor-scheer
Copy link
Contributor

Keyv supports the use of get in an overloaded manner. Pass a single key, get a single result; pass an array of keys, get an array of results.

The current typings as they're written return a singular Value in both cases. By overloading this method, we can get the correct return type string -> Value | undefined, string[] -> (Value | undefined)[].

@trevor-scheer trevor-scheer changed the title Add multi-key get typings overload Add multi-key get typings overload Jun 13, 2022
@jaredwray
Copy link
Owner

@trevor-scheer - can you get the linting fixed on these? Most likely you can do a xo --fix

@trevor-scheer
Copy link
Contributor Author

@jaredwray it did fix some things but also spit out these errors (unrelated to my changes)

trevorscheer@Trevors-MBP keyv % npx xo --fix

  packages/memcache/test/test.js:1:21
  ✖    1:21  Do not use "require".                                                           unicorn/prefer-module
  ✖    2:14  Do not use "require".                                                           unicorn/prefer-module
  ✖    3:14  Do not use "require".                                                           unicorn/prefer-module
  ✖    4:22  Do not use "require".                                                           unicorn/prefer-module
  ✖    6:14  Do not use "require".                                                           unicorn/prefer-module
  ✖   12:1   Do not use "require".                                                           unicorn/prefer-module
  ✖   16:5   Unexpected use of the global variable process. Use require("process") instead.  node/prefer-global/process
  ✖   17:8   Unexpected use of the global variable process. Use require("process") instead.  node/prefer-global/process
  ✖   32:33  Function was declared as async but doesn't use await.                           ava/no-async-fn-without-await

  packages/memcache/src/index.js:1:1
  ✖    1:1   Do not use "use strict" directive.                                              unicorn/prefer-module
  ✖    3:22  Do not use "require".                                                           unicorn/prefer-module
  ✖    4:18  Do not use "require".                                                           unicorn/prefer-module
  ✖    5:15  Do not use "require".                                                           unicorn/prefer-module
  ✖  143:32  reject is defined but never used. Allowed unused args must match /^_/u.         no-unused-vars
  ✖  155:1   Do not use "module".                                                            unicorn/prefer-module

  packages/memcache/src/index.d.ts:13:26
  ✖   13:26  any overrides all other types in this union type.                               @typescript-eslint/no-redundant-type-constituents

  packages/mongo/src/index.js:134:43
  ✖  134:43  Prefer utf8 over utf-8.                                                         unicorn/text-encoding-identifier-case

  17 errors

@jaredwray
Copy link
Owner

@trevor-scheer - thanks go ahead and roll back the changes and we can fix them on our side then will bring in your type fix.

@trevor-scheer trevor-scheer force-pushed the trevor/fix-getmany-typings branch from 50d997a to 719adb9 Compare June 14, 2022 19:03
@trevor-scheer
Copy link
Contributor Author

Ok. I get a ton of errors when I run yarn test. Is there a certain local setup I need to do for things to work?

Reverted the original lint, this time just committed changes to the file I edited.

@jaredwray
Copy link
Owner

Looks like xo version 0.50.0 has some breaking changes that needs to fix and also memcache package needs to get updated to be compliant.

to test the project just download the latest and then do the following:

  1. run yarn
  2. run yarn test:services:start make sure you have docker installed and running
  3. Wait about 30 seconds for all the services to start up
  4. run yarn test -- this will test all the major packages with the current setup including xo lint

@codecov
Copy link

codecov bot commented Jun 14, 2022

Codecov Report

Merging #359 (719adb9) into main (a229f4d) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main      #359   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           18        18           
  Lines         1113      1113           
=========================================
  Hits          1113      1113           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a229f4d...719adb9. Read the comment docs.

@jaredwray jaredwray merged commit 7102dc3 into jaredwray:main Jun 14, 2022
@jaredwray
Copy link
Owner

@trevor-scheer - this will be released in the next week or so with other updates being tested

@trevor-scheer trevor-scheer deleted the trevor/fix-getmany-typings branch June 14, 2022 19:29
@trevor-scheer
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants