In most programming languages a variable has a type and that type does not change. But one of the most interesting aspects of TypeScript's type system is that a symbol has a type at a location. Various control flow constructs can change this type: function refine(x: string | number) { // type of x is string | number here if (typeof x === 'number') { // type of x is number here. } else { // type of
![Effective TypeScript › Flow Nodes: How Type Inference Is Implemented](https://cdn-ak-scissors.b.st-hatena.com/image/square/cca7489e6860c329f9c74bee236243e8660fb54b/height=288;version=1;width=512/https%3A%2F%2Feffectivetypescript.com%2Fimages%2Fcover.jpg)