I would like to obtain the following behaviour without using a T as any:
interface Test<T> {
sameField: string;
test: T
testFunction: (e: T) => void
}
const array: Array<Test</*something something*/_>> = [
{
sameField: "foo",
test: 1,
testFunction: (e) => {
e.toExponential(2) // Should be Valid
e.indexOf('e') // Should be Invalid
}
},
{
sameField: "bar",
test: "baz",
testFunction: (e) => {
e.indexOf('e') // Is Valid
e.toExponential(2) // Should be Invalid
}
}
]
The idea behind it is just a way of telling Typescript "let the array elements handle their typing themselves". Is it only possible to do in Typescript ?