Generic parameter defaults in arrow functions confused as jsx elements in tsx files #45939
Closed
Description
const OkInTsx = function <A = string>() {
return 'ok in ts file';
};
export const BrokeInTsx = <A = string>() => {
return 'ok in ts file';
};
To replicate, copy that code in a ts file (v3.3+ tested, updated vscode). It should be ok. Rename ts to tsx and the generic parameter default will be considered a jsx element and therefore a syntax error. I discovered this doing some codegen into a tsx file. If we are writing our own code, we can work around, but it seems jsx and generic parameter defaults on arrow functions aren't working together at the moment.