reflection – Finding types in TypeScript

Is there a way to learn what the type of something is at runtime, so that I can go back and fill in the type later?

TypeScript uses type erasure and does not run at runtime:

Current proposals for adding gradual typing to JavaScript, such as
Closure, TypeScript and Dart, forgo soundness to deal with issues
of scale, code reuse, and popular programming patterns.

Use an alternative, such as the following:

JS++® introduces the first and only type system compatible with JavaScript that is optional and “sound.”

In other words, if you choose to declare the type for a variable, it is guaranteed to always be correct — during compile-time checking and runtime execution — even if you’re using “untyped” JavaScript libraries.

JavaScript offers five ways: typeOf and instanceOf, isPrototypeOf, constructor, and Object.getPrototypeOf:

typeof 1;

/foo/ instanceof RegExp