Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Fix Best common type. #592

Merged
merged 3 commits into from
Aug 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pages/Type Inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ To correct this, instead explicitly provide the type when no one type is a super
let zoo: Animal[] = [new Rhino(), new Elephant(), new Snake()];
```

When no best common type is found, the resulting inference is the empty object type, `{}`.
Because this type has no members, attempting to use any properties of it will cause an error.
This result allows you to still use the object in a type-agnostic manner, while providing type safety in cases where the type of the object can't be implicitly determined.
When no best common type is found, the resulting inference is the union array type, `(Rhino | Elephant | Snake)[]`.

# Contextual Type

Expand Down