Closed nvlang closed 2 months ago
Duplicate of #9998.
typeof
in that position is going to use the non-control-flowed (i.e. declared, not narrowed) type of the variable, and pointer
and functionOrArray
have different declared types
This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
š Search Terms
inconsistent inference of type of pointer / alias in generic function
š Version & Regression Information
āÆ Playground Link
https://www.typescriptlang.org/play/?ts=5.6.0-dev.20240701#code/KYDwDg9gTgLgBAMwK4DsDGMCWEV1AQwFswAbYAHgDUA+ACgCg4nFUNsUB5KAQSinwCeALkbMxAHzi1aASjgBeanFQATYAkwpgKmaLFNJtSnhAxgKFQGc4lmFE0BzOAH44lANoBdOEOUX1mtoyADT0cgDeenCYCFK8-AIAdJiW8YK0yOhYOFxpAjIRcFFiaDi2cJCaZlAKLFnsuXyCANxF+sxk8ABu+CS+tDACYMAQsZlsOTxN+e4oSIQARsBQnq0A9GtwEADWgsUdwPAOSPhQKgCM-V2+qNsoEADuKHKKcF3R1gNDI2Os2ZxTBIyWbzJYrdabZZQaD7JidODHU4qABMVxuKDuj2eCiU7xSUkGw1GFQgVWWwLmi2WqzgGy2uwEUQAvkx6EygA
š» Code
š Actual behavior
(v: unknown) => v is (typeof alias)[number]
works, but(v: unknown) => v is (typeof functionOrArray)[number]
doesn't.š Expected behavior
Expected
alias
andfunctionOrArray
to either both work or both not work.Additional information about the issue
No response