TypeScript Using generic Classes and Functions:


Example

Create generic class instance:

var stringRunnable = new Runnable<string>();

Run generic function:

function runSafe<T extends Runnable<U>, U>(runnable: T);

// Specify the generic types:
runSafe<Runnable<string>, string>(stringRunnable);

// Let typescript figure the generic types by himself:
runSafe(stringRunnable);