Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upIdea: Required property accessor #1221
Comments
adrianhelvik
changed the title from
Required property accessor
to
Idea: Required property accessor
Jun 8, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ljharb
Jun 8, 2018
Member
Please see the proposal repo for optional chaining, as well as https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md for how to best suggest new ideas.
Separately, foo?.bar tells you something about foo, not bar - as such, foo!.bar would have to have behavior based on foo - not foo.bar - for consistency.
|
Please see the proposal repo for optional chaining, as well as https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md for how to best suggest new ideas. Separately, |
adrianhelvik commentedJun 8, 2018
It would be nice to have foo!.bar alongside foo?.bar.
foo!.bar could then throw if foo.bar === undefined.
Useful when using process.env in Node and for debugging. Its primary use case would be for when undefined is unacceptable:
The reason I think allowing nulls is a good idea is that they are generally explicitly specified, whereas undefined is usually not what you want.