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

Commit

Permalink
Merge pull request #592 from vomvoru/patch-1
Browse files Browse the repository at this point in the history
Fix Best common type.
  • Loading branch information
mhegazy authored Aug 14, 2017
2 parents a12ad03 + 4c6bd50 commit 88a4afa
Showing 1 changed file with 1 addition and 3 deletions.
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

0 comments on commit 88a4afa

Please sign in to comment.