Skip to content
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

No error thrown when calling concat with T[] and T[][] #55844

Closed
thomasschafer opened this issue Sep 23, 2023 · 2 comments
Closed

No error thrown when calling concat with T[] and T[][] #55844

thomasschafer opened this issue Sep 23, 2023 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@thomasschafer
Copy link

thomasschafer commented Sep 23, 2023

πŸ”Ž Search Terms

"concat", "concat wrong type", "concat no error"

πŸ•— Version & Regression Information

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

⏯ Playground Link

https://www.typescriptlang.org/play?ts=3.3.3#code/MYewdgzgLgBAhgJwQRhgXhgbU8gurgKFElkQQCZ14lkA6Y4OKACk3NwEojwIQAbAKa0+IAObMy5LtxLUEAZirYARHGX4Z0OQBYqZefXCMWmZQCN1XYr0HCxEpNo5A

πŸ’» Code

const arr1 = [[1]]
const arr2 = arr1.concat([2]) // No error

const arr3 = [["a"]]
const arr4 = arr3.concat(["b"]) // No error

πŸ™ Actual behavior

No error is shown, and type of the result is incorrectly inferred as T[]

πŸ™‚ Expected behavior

Either an error should be shown, or the result of concat should be (T | T[])[]

Additional information about the issue

No response

@MartinJohns
Copy link
Contributor

Duplicate of #36554 (comment).

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Sep 26, 2023
@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 Sep 29, 2023
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