Allow optional property syntax, similar to typescript with key?: value
See original GitHub issueIt would be great for users coming from typescript to be able to write the following:
type ObjectType = {
key?: string
}
const test: ObjectType = {};
Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to Deal with Optional Things and "Undefined" in TypeScript
First, if you don't tell TypeScript that a property is optional, it will expect it to be set. Adding ? to the property...
Read more >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 >Optional property class in typescript - Stack Overflow
When someone will use your interface IEmployee then middleName will be optional but firstName and lastName is compulsory. let emp: IEmployee = { ......
Read more >How to Make Certain Properties Optional in TypeScript
In the above example, the pet is an optional property. It's useful, but every time you would like to perform some operations on...
Read more >Interfaces with Optional Properties - TypeScript - LogicBig
In TypeScript, the interfaces which describe objects can have optional properties. Interfaces with optional properties are written similar ...
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
Object.keys
andObject.entries
also give different results when prop is not there vs when prop is undefinedIt’s true. And also we infer the keys result from the object type.