yytypescript / book

TypeScriptの入門書『サバイバルTypeScript』
https://typescriptbook.jp
939 stars 103 forks source link

Wouldn't the following sample code be better? (タプル型の例としては異なる型のペアのほうが例として好ましくないですか?) #849

Open RHxyz009abc opened 6 months ago

RHxyz009abc commented 6 months ago

Features of TypeScript. Advanced type expression.

  1. Tuple type: A type that allows you to specify a different type for each element of the array. type Point2D = [number, number];

https://github.com/yytypescript/book/blob/93c3a5c342988a97274a1eea4d09ab8a6cdaf201/docs/overview/features.md?plain=1#L56

Wouldn't the following sample code be better? type Point2D = [number, string];

suin commented 5 months ago

Certainly! Having different types in a tuple indeed showcases the unique capability of tuple types more effectively. However, including a string in Point2D might seem unnatural, suggesting that a significant change to the example could be beneficial.

ja: たしかに!異なる型同士のほうが、タプル型らしさが出ますね。Point2Dがstringを持つのは不自然なので、例を大きく変える必要はありそうですね。