question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve the TypeScript types

See original GitHub issue

Issuehunt badges

I think the types could still be improved.

  • Would be good to use unknown instead of any here: https://github.com/sindresorhus/conf/blob/bb24cfe32d39617a4b3983a92bd81596bd87c312/index.d.ts#L210 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} = {…};. https://github.com/sindresorhus/conf/blob/bb24cfe32d39617a4b3983a92bd81596bd87c312/index.d.ts#L50
  • 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

superjo149 superjo149 has been rewarded.

Backers (Total: $80.00)

Submitted pull Requests


Tips

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
issuehunt-app[bot]commented, Jul 3, 2020

@sindresorhus has rewarded $72.00 to @superjo149. See it on IssueHunt

  • 💰 Total deposit: $80.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $8.00
1reaction
sindresorhuscommented, Feb 22, 2020

For anyone that wants to work on this, see the initial attempt and feedback in https://github.com/sindresorhus/conf/pull/96. You can start from there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Advanced Types - TypeScript
This page lists some of the more advanced ways in which you can model types, it works in tandem with the Utility Types...
Read more >
Write fewer tests by creating better TypeScript types
Type -driven development is writing your TypeScript program around types and choosing types that make it easy for the type checker to catch...
Read more >
Effective TypeScript: 62 Specific Ways to Improve Your ...
Avoid TypeScript object wrapper types. Use the primitive types instead: string instead of String, number instead of Number, boolean instead of Boolean, symbol ......
Read more >
How I improve my skills in Typescript #1 : Typeguard & Type ...
I will share with us some tips that improved my skill in Typescript ! Typeguard. Typeguard allow you to validate the type of...
Read more >
Improve your TypeScript Skills with Type Challenges
Improve your TypeScript Skills with Type Challenges ... Typescript is the superset of JavaScript. The repository of Typescript challenges makes it ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found