NoInfer
isn't erased and breaks type narrowing
#58266
Labels
Milestone
NoInfer
isn't erased and breaks type narrowing
#58266
π Search Terms
NoInfer
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.5.0-dev.20240419#code/C4TwDgpgBAglC8UDeB9YBDA5gLigInTwF8AoUSKAIQWTS1zwCNiSzxoBVGuAHytYD0AqOWgA5APYBJAHYAzCACcATAB4YAPm6sAxhJkBnYFAC2uJIogGArgBtguSbIWLVHDUQDaAXRo-WctYyOsAAlvqm6GDqADRUGgAUocAQJga4lugAJvq2ILA+cXK4CeiO0vJK6hoAlAhalHVIUJbA1ooyUFDJqQYAdCZRCXJ1pEJQEDJZBlDWYFDoM1AJzZY29uXOVe4A3FBEUHwydrY1Pt2GKdlQEnLLq1Z2DrB7B0cnZ94kepdQBhImCDAAAWoRkmBogzACRMcQSKDq8C0KD6ayefToEPg2PwhCgAH5kFA+iSUHE0RsoCiKcYDrhjrZTiQgA
π» Code
π Actual behavior
ends up as
({ result: NoInfer<U>; } | null)[]
π Expected behavior
({ result: A; } | null)[]
Additional information about the issue
use the custom
NoInfer2
type instead, and it works as expected.Here's the actual source that lead me to the problem https://www.typescriptlang.org/play#code/JYWwDg9gTgLgBAbzgQSlAhgTwDRwKIBmBApgMYy4DyYMwEAdnAL5wFQQhwBExRZMXAFCDSDAM7woxMQFcANjDFwAvHADahEuQB0s0qWLEAJgAoAjAEptYYGGInN-bcQAewCvj4709IwBUAC2J6E1d3FQA+OBMkMPgmCwtcRx0oGXoAZUx6UgsAXWFReglWdGA5YxUUNCxtAnKYYigAWXQwEylZBTFcEwB9C0jBOBG+5zcYbT6YdABzFWVVLgAxMrkZKS44AH44aloGXQ57JG0zvtw4gC44MbjmQZv9unptegZ7C0EvoA
The text was updated successfully, but these errors were encountered: