Required types
See original GitHub issueFirstly, 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:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just had the same issue and fixed it by setting
strict: true
option in my typescript configuration.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!