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

Improve the TypeScript types #86

Open
sindresorhus opened this issue Sep 9, 2019 · 4 comments · May be fixed by #91

Comments

@sindresorhus
Copy link
Owner

commented Sep 9, 2019

Issuehunt badges

I think the types could still be improved.

  • Would be good to use unknown instead of any here:

    conf/index.d.ts

    Line 210 in bb24cfe

    declare class Conf<T = any> implements Iterable<[keyof T, T[keyof T]]> {
    But it causes error on a valid usage:
     index.test-d.ts:123:13
       ✖  123:13  Argument of type "debug phase" is not assignable to parameter of type never.
    
  • You cannot use dot-paths with a typed store: config.set('foo.bar', true);. We need to find a way to support that. Could possibly add support for config.set(['foo', 'bar'], true).
  • Reduce duplication if you use both a typed store and the defaults option. Maybe using the const keyword.
  • Could we make the types even stricter?
  • Expose the type of the schema option, so it's easier to define it as a variable before passing it. Currently, you would have to do const schema = {[Key in keyof TypedStore]: Conf.Schema} = {…};.
    readonly schema?: {[P in keyof T]: Schema};
  • Maybe rename the current Schema type to something clearer like SchemaValue, SchemaOptionValue? Need some naming suggestions.

I'm open to other ideas on how to improve the types.


IssueHunt Summary

Backers (Total: $80.00)

Become a backer now!

Or submit a pull request to get the deposits!

Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

@issuehunt-app

This comment has been minimized.

Copy link

commented Sep 9, 2019

@issuehunt has funded $80.00 to this issue.


@brunolemos

This comment has been minimized.

Copy link

commented Sep 9, 2019

I highly recommend moving from index.js to index.ts for automatic type generation.

@satyarohith

This comment has been minimized.

Copy link

commented Sep 12, 2019

I would like to work on this.

@satyarohith satyarohith referenced a pull request that will close this issue Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.