🔎 Search Terms
TS2604
🕗 Version & Regression Information
This is a regression, it started happening with 5.4.0
Note that that comment lists 2 issues, now there's only the one TS2604 issue.
The issue still exists in @next.
⏯ Playground Link
https://www.typescriptlang.org/play?#code/PTAEEsBcHIGdQIoHdwGtQCMCulQHtUBYAKHAFsAHPAJ1wCUBTAQwGNcAzavM0aa5ttBIkQoACoALcPGmh+ARyzh+AE1DsaoSBIYRYsLAwA0oFhKYA7AObhrEXJDxyGkLNQvjQZJqgYzcTKAq4OzsDPwWuOFc1CSQAJ4UugDyGABWDGwAClwUsAA8YgB8oAC8JKCVngwAHpAMFirwjCw0KvmW8SadRRVVAPzifZUAXKAWDABu4QDcwsQJSaAAYlgWbOB4FgDC3FQTkflZZaBrqBZ4SBYlpaAAFBS5sGNZAJRlJZ1zxCJgsJDUWxWAA+7A8sgUSlU6k02l00gMxlM5msQPsWicWwANvFkZl0BpqOoPN5fP5QIFgqFwg0otQYnFErocng8sl2PltskALJZG6gLm80C1eqNeC+eJ4digABSAGUABoAOgAkpFARZYOAWABRLEMMi02DDUCDeXKtUA2xa3X6w2RWAAbUFWQAuiaxi7hXUGk0VmsNltdpQtrT8rYwkTkoCrCy8r1iFVTaBUhlsk98tHwLGngmk2MJtNYj9iK1NbgsngcWUTZzvaK-f8NVZQMD-etIJsdntQ5ETk20W3Vh2u8H9rSincAN4mpNMZ4CygnaDBSbQCnwbZGWdVJV7x6s42JqoAXzGU43-U9oBPoAAZKA47B2fkB3YRb7N8mV+A16BPUU7ylCUM7HkmlSiJIsjBCoFjQHSMQQB4ACsSoAMzoZgODCvSNAyChSoACxKgADDulT8K47igJyS5TnuSoHnkJ5FFI+TANslBFN84FVKI4EAHr9CaJ7zEAA
💻 Code
// it's Qwik but okimportReactfrom'react'// This is required for the issue, changing it to return T makes it a different errortypeObjectProps<T>=TextendsRecord<any,any>
? T
: never;typeFunctionComponent<P=unknown>=(props: P)=>any;// string|fn is required for the issue, changing it to only check for fn makes it a different errortypePropsOf<COMP>=COMPextendskeyofJSX.IntrinsicElements
? JSX.IntrinsicElements[COMP]
: COMPextendsFunctionComponent<infer OrigProps>
? ObjectProps<OrigProps>
: neverconstPoly=<Cextendsstring|FunctionComponent=string|FunctionComponent>({as: Cmp='div'asC,
...props}: {as?: C}&PropsOf<stringextendsC ? 'div' : C>)=>{// This didn't error in 5.3.3 but errors in 5.4.0return<Cmp{...props}>hi</Cmp>;// ^?}In 5.3.3, the type of Cmp is roughly String|FunctionComponent, and in 5.4.2 it's C|(C&string)
🙁 Actual behavior
It can't determine that Cmp is a function
🙂 Expected behavior
It should determine that Cmp is a valid JSX tag
Additional information about the issue
No response
🔎 Search Terms
TS2604
🕗 Version & Regression Information
This is a regression, it started happening with 5.4.0
Note that that comment lists 2 issues, now there's only the one TS2604 issue.
The issue still exists in @next.
⏯ Playground Link
https://www.typescriptlang.org/play?#code/PTAEEsBcHIGdQIoHdwGtQCMCulQHtUBYAKHAFsAHPAJ1wCUBTAQwGNcAzavM0aa5ttBIkQoACoALcPGmh+ARyzh+AE1DsaoSBIYRYsLAwA0oFhKYA7AObhrEXJDxyGkLNQvjQZJqgYzcTKAq4OzsDPwWuOFc1CSQAJ4UugDyGABWDGwAClwUsAA8YgB8oAC8JKCVngwAHpAMFirwjCw0KvmW8SadRRVVAPzifZUAXKAWDABu4QDcwsQJSaAAYlgWbOB4FgDC3FQTkflZZaBrqBZ4SBYlpaAAFBS5sGNZAJRlJZ1zxCJgsJDUWxWAA+7A8sgUSlU6k02l00gMxlM5msQPsWicWwANvFkZl0BpqOoPN5fP5QIFgqFwg0otQYnFErocng8sl2PltskALJZG6gLm80C1eqNeC+eJ4digABSAGUABoAOgAkpFARZYOAWABRLEMMi02DDUCDeXKtUA2xa3X6w2RWAAbUFWQAuiaxi7hXUGk0VmsNltdpQtrT8rYwkTkoCrCy8r1iFVTaBUhlsk98tHwLGngmk2MJtNYj9iK1NbgsngcWUTZzvaK-f8NVZQMD-etIJsdntQ5ETk20W3Vh2u8H9rSincAN4mpNMZ4CygnaDBSbQCnwbZGWdVJV7x6s42JqoAXzGU43-U9oBPoAAZKA47B2fkB3YRb7N8mV+A16BPUU7ylCUM7HkmlSiJIsjBCoFjQHSMQQB4ACsSoAMzoZgODCvSNAyChSoACxKgADDulT8K47igJyS5TnuSoHnkJ5FFI+TANslBFN84FVKI4EAHr9CaJ7zEAA
💻 Code
In 5.3.3, the type of Cmp is roughly
String|FunctionComponent, and in 5.4.2 it'sC|(C&string)🙁 Actual behavior
It can't determine that Cmp is a function
🙂 Expected behavior
It should determine that Cmp is a valid JSX tag
Additional information about the issue
No response