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

Chapter 4 Exercise 5 #10

Open
TheGhostHuCodes opened this issue Oct 27, 2020 · 2 comments
Open

Chapter 4 Exercise 5 #10

TheGhostHuCodes opened this issue Oct 27, 2020 · 2 comments

Comments

@TheGhostHuCodes
Copy link

Thanks for writing this great book. I'm new to TypeScript and I'm enjoying working through it.

I noticed that the answer to Chapter 4 Exercise 5 has the function signature:

function is<T>(a: T, ...b: [T, ...T[]]): boolean

However, when I was attempting it on my own, I came up with:

function is<T>(a: T, ...b: T[]): boolean

which also seems to work. It looks like there's also an open PR (#8) with the signature:

function is<T>(a: T, ...b: [...T[]]): boolean

What's the difference, if any, between these different generic types?

@tmnvanderberg
Copy link

I came here to ask the same question.

@tmnvanderberg
Copy link

tmnvanderberg commented Apr 23, 2022

Just noticed the question was answer on the PR. The reason is to avoid users calling is('a') with a single argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants