Typescript introduces support for the JSX syntax. So I have an expression that works quite well with traditional *.ts files but no with *.tsx ones:
const f = <T1>(arg1: T1) => <T2>(arg2: T2) => {
return { arg1, arg2 };
}
This is an unfortunate side effect of syntax ambiguities. You need to either have an extends clause or multiple type parameters. You can write an extends clause that is functionally equivalent (albeit annoying):
const f = <T1 extends {}>(arg1: T1) => <T2 extends {}>(arg2: T2) => {
return { arg1, arg2 };
}
That almost worked for me.
To cover all the types including null
, I believe it technically should extend any
:
const f = <T1 extends any>(arg1: T1) => <T2 extends any>(arg2: T2) => {
return { arg1, arg2 };
}
I think it better communicates that it's no-op too, while extending {}
can look like it is a real restriction it wants to enforce.
Most helpful comment
This is an unfortunate side effect of syntax ambiguities. You need to either have an extends clause or multiple type parameters. You can write an extends clause that is functionally equivalent (albeit annoying):