Closed
Description
Consider a situation when each class and function in the module depends on the same type/value parameters:
// current
module foo {
export class C<a> {
value: a;
constructor(private areEqual: (one: a, another:a) => boolean) { /*...*/ }
}
export function f1<a>(areEqual: (one: a, another: a) => boolean, ones: a[], anothers: a[]) : boolean {
// ...
}
export function f2<a>(areEqual: (one: a, another: a) => boolean, values: a[], sample: a): number[] {
// ...
}
}
It would be awesome if such parameters went to the module level and were resolved at importing
// suggested
module foo<a>(areEqual: (one: a, another: a) => boolean) {
export class C {
value: a;
}
export function f1(ones: a, anothers: a): boolean {
//...
}
export function f2(values: a[], sample: a): number[] {
//...
}
}
import foo = require('foo')((one: Date, another:Date) => one.getTime() === another.getTime());