I'm a beginner in TypeScript and I'm trying to write a method with a generic type argument similar to what you can do in .Net.
Here's the code snippet I've been working on:
class TestObject {
Id: number;
Truc: string;
Machin: string;
}
export default
{
async FirstMethod(): Promise<TestObject> {
return await this.TestMethodGen<TestObject>();
},
async TestMethodGen<T>(): Promise<T> {
// Json Deserialization other etc ...
return <T>new Object();
}
}
However, I keep running into a TypeScript error TS2347 and I'm unsure of how to fix it.
TS2347 (TS) Untyped function calls may not accept type arguments.
https://i.sstatic.net/sYtwk.png
Thank you in advance for any assistance.