Typescript types do not work on undefined as first parameter
See original GitHub issueThe following does not work:
const myVar: { a: { b: string } } | null = null as {
a: { b: string };
} | null;
const something = idx(myVar, _ => _.a.b);
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Documentation - Do's and Don'ts - TypeScript
Don't ever use the types Number , String , Boolean , Symbol , or Object These types refer to non-primitive boxed objects that...
Read more >typescript - Require argument if unknown type is not undefined
If a function parameter is optional, then it will accept undefined as a value. But the converse is not necessarily true; just because...
Read more >typescript-cheatsheet - GitHub Pages
A set of TypeScript related notes used for quick reference. The cheatsheet contains references to types, classes, decorators, and many other TypeScript ......
Read more >7 The essentials of TypeScript - Exploring JS
In this chapter, a type is simply a set of values. The JavaScript language (not TypeScript!) has only eight types: Undefined: the set...
Read more >optional vs. undefined - TkDodo's blog
The first one means: This parameter is optional. ... because TypeScript was not complaining (I do rely on that a lot), as all...
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
Thanks, @Horaddrim.
Sounds like this question has been resolved.
@Horaddrim This doesn’t solve the problem for me.
still fails the build.
Please let me know if I failed any etiquette by opening a new issue. I’m not sure if I was supposed to do that-- sorry if I’m being annoying!