Open simply-none opened 7 months ago
Where is the error?
Where is the error?错误在哪里?
look: by the document context,the example is error.
Oh, I got your point. But in this case, I think they mean this: (By the word "instead", they're replacing all overloaded signatures with the union type any[] | string
)
Because both overloads have the same argument count and same return type, we can instead write a non-overloaded version of the function:
Oh, I got your point. But in this case, I think they mean this: (By the word "instead", they're replacing all overloaded signatures with the union type
any[] | string
)哦,我明白你的意思了。但在这种情况下,我认为他们的意思是:(通过“代替”这个词,他们正在用联合类型any[] | string
替换所有重载的签名)Because both overloads have the same argument count and same return type, we can instead write a non-overloaded version of the function:由于两个重载具有相同的参数计数和相同的返回类型,因此我们可以改为编写函数的非重载版本:
oh, i get it. thank you!
Page URL: https://www.typescriptlang.org/docs/handbook/2/functions.html#writing-good-overloads
Issue:
the example is error:
Because both overloads have the same argument count and same return type, we can instead write a non-overloaded version of the function:
above has some problems in typescript playground:
correct is that: