Skip to content

Array.flatMap incorrectly narrows types. #61168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bweis opened this issue Feb 12, 2025 · 2 comments
Closed

Array.flatMap incorrectly narrows types. #61168

bweis opened this issue Feb 12, 2025 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@bweis
Copy link

bweis commented Feb 12, 2025

πŸ”Ž Search Terms

  • flatMap
  • Array.flatMap

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about flatMap

⏯ Playground Link

https://www.typescriptlang.org/play/?target=6&ts=5.7.3#code/C4TwDgpgBAglC8UDeAoK6qkgLigIhjzQwDcBDAGwFcJcBnYAJwEsA7AcxQF8UUtoAQgmTF0-XHgFEMUctVpQGLDqKhs6zACYKAwgG0Aut178oO4ahlyauVlQC2AIwiNjvAMYB7VgyhlGjGQguDABQQA8cAA+UAIAfMJ6SOL4hAA0spQ2+ACMeFwZyeAKBHgZ1iUATPmFKZJlmfISeRnqWgpJFbgAzAXIXVAALFwGfUU4+FLlWVUNbdq4nTO4AKxjAwDsIyO8KAD0e2ZkdNA5uAAinhB0UKyewFAA7p6MANYoXj4PAGaensL+QIgAB03woZGAAFkyGAABSwioASgQCUsGGY3ygCJmwNM8HxqTwyLRMnQjAgwCojFYjRoqi4UAgFBOakx2PkuOKCAJ9WJqhk5Mp1NpEGB8wg9NUn18AH0qKxyWR3AALMiOCgKVgQEguYQVVSCqk0uUKiBK1XqiVcRG7A5HFmVXAAJQgAEcqMxyTcIAAPMAUZjuZgPbTfNjB5jeTD-Z5vD7eXyOfwAsIgsEQ6FgSJQGI6OLwpEokQyDFYiqcyDcxClPmkjCG4X6mQMpks0vsmgV6D46tSWt1qANmnl8WSmTSh4mxUqtUa2za3WIJv1ilGqBTs0zy3cG22w46Y7Qbq4ADyjCg9hhGWAyogNPTwGB8a+UCTAC8U0DgZe4R2IMj4FRVR23LPEeUIfs6yHEV6UZZloBAnEwN7IliwHaCRx8doxwwCd13lacLTnW4F3PJcZgNVdhQ3c1ZytRFQXBYBYURIA

πŸ’» Code

// Your code here

πŸ™ Actual behavior

I replicated additional cases in the playground link. I would expect the type narrowing to work in case 1, as it does in case 2 and case 3.

πŸ™‚ Expected behavior

I replicated additional cases in the playground link. I would expect the type narrowing to work in case 1, as it does in case 2 and case 3.

Additional information about the issue

No response

@jcalz
Copy link
Contributor

jcalz commented Feb 12, 2025

duplicate #31033

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Feb 12, 2025
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants