Skip to content

Commit e0d966f

Browse files
authored
Merge pull request microsoft#751 from buncismamen/master
Add `object` to basic types handbook
2 parents 302af1b + fac5ed6 commit e0d966f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pages/Basic Types.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,24 @@ function infiniteLoop(): never {
240240
}
241241
```
242242

243+
# Object
244+
245+
`object` is a type that represents the non-primitive type, i.e. any thing that is not `number`, `string`, `boolean`, `symbol`, `null`, or `undefined`.
246+
247+
With `object` type, APIs like `Object.create` can be better represented. For example:
248+
249+
```ts
250+
declare function create(o: object | null): void;
251+
252+
create({ prop: 0 }); // OK
253+
create(null); // OK
254+
255+
create(42); // Error
256+
create("string"); // Error
257+
create(false); // Error
258+
create(undefined); // Error
259+
```
260+
243261
# Type assertions
244262

245263
Sometimes you'll end up in a situation where you'll know more about a value than TypeScript does.

0 commit comments

Comments
 (0)