Multiple type signatures for members, Union Types in TypeScript
Solution 1:
As of 2015, union-types work:
interface Foo {
bar:string|boolean;
}
Solution 2:
This is usually referred to as "union types". The TypeScript type system from 1.4 does allow for this.
See: Advanced Types
Solution 3:
Not saying this answers your question, but could you resort to something like this?
interface Foo<T>{
bar:T;
}
function createFoo<T>(bar:T) : Foo<T>{
return {bar:bar};
}
var sFoo = createFoo("s");
var len = sFoo.bar.length;
var bFoo = createFoo(true);
var result = bFoo.bar === true;