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.

Firstly, apologies if this isn’t an actual issue and is instead related to my naivety as to how to properly use the library.

Secondly, this is a great library.

My issue is relating to determining that a type is required, and not ever undefined, as far as the Typescript compiler is concerned.

If I have some code:

const testDecoder = object({ success: boolean });

TS determines the type to be:

Decoder<{
    success?: boolean;
}, unknown>

My question is, how can I have typescript infer that the key success is not optional?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dam5scommented, May 8, 2021

I just had the same issue and fixed it by setting strict: true option in my typescript configuration.

1reaction
OliverRadinicommented, Feb 27, 2021

Thanks for getting back to me; the example in that issue works fine for me, which is great, I’ll have a look at the code I have and attempt to see what the difference is, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Utility Types - TypeScript
Utility Types · Awaited<Type> · Partial<Type> · Required<Type> · Readonly<Type> · Record<Keys, Type> · Pick<Type, Keys> · Omit<Type, Keys> · Exclude<UnionType, ...
Read more >
How the TypeScript Required Type Works - Fjolt
The Required type is a utility type which sets all properties in a type to required. Let's look at how it works.
Read more >
TypeScript utility types: Partial and Required - Daily Dev Tips
These are utilities we can use to do type transformations. This article will look at the Partial and Required types.
Read more >
Requirement Types - AcqNotes
Requirements Development​​ The main types of requirements are: Functional Requirements. Performance Requirements. System Technical Requirements.
Read more >
How the TypeScript Required Type Works - DEV Community ‍ ‍
As with other utility types, Required is meant to work with an interface or object type, like the User type we defined above....
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