2 ms·
Can I type stuff as any but still non nullable?
by k__ 9y ago
Can I type stuff as any but still non nullable?
- seanmcdirmid 9y agoI think any in TypeScript's context means "not in the type system", and all type rules bounce off it. So if k's type is any, and you type k.foo, it doesn't bother checking it. I assume the same applies to any null checking.
- k__ 9y agoThe "object" type is probably what I was searching.
- spiralx 9y agoThe object type is the type of all non-primitive types, what you want is the Object type instead. Yes, it's confusing, especially as there's also the {} type! This article goes over the differences: https://blog.mariusschulz.com/2017/02/24/typescript-2-2-the-object-type https://blog.mariusschulz.com/2017/02/24/typescript-2-2-the-...