(Context: using TS in a RN project is currently a bit disjointed because of its closed dev bundling workflow. You need a separate build task running concurrently to feed JS files to the main watch/build task.)
This is incorrect, as is the announcement. The following is valid.
class Bar{}
let foo:object = new Bar()
foo = null
foo = undefined
edit:For the people mentioning, --strictNullChecks. That applies to all types not just object. For example, "let x:string = null" would also be an error. That option applies to any type that is not of type Any/null/undefined, and has been in place since 2.0. In that way, "object" is non-nullable under strictNullChecks just as every other type is.
Anyway, TypeScript's `strictNullChecks` in general has a huge hole in that it allows uninitialized properties (https://github.com/Microsoft/TypeScript/issues/8476).
For your code to work, you'd need to run it with strictNullChecks disabled. That's probably what you're doing, since it's the default.
It's not the default for the command line compiler. Also, all types (except Any/null/undefined) are non-nullable under that option, so that's not what makes object special (it's the no primitive types that is important).
>tsc test.ts
>tsc test.ts --strictNullChecks
> test.ts(3,1): error TS2322: Type 'null' is not assignable to type 'object'.I think you misinterpreted my reply. I meant the default is off. That's what your code shows.
1: https://www.typescriptlang.org/docs/handbook/compiler-option...
The initial suggestion was made because there are certain functions in JavaScript that expect a non-primitive type in order to function. Such as Object.create, Object.getPrototypeOf, etc. Previous to this there was no way to model the functions with type safety, such that a developer would be prevented from accidentally sending a primitive value into those functions. This is because Typescript doesn't have the ability to say "Any type except X, Y and Z". So a new type was needed for this.