reactjs / react.dev

The React documentation website
https://react.dev/
Creative Commons Attribution 4.0 International
11.03k stars 7.53k forks source link

[Typo]: There is a syntax mistake on react docs GetStarted/Installation/Using Typescript #6697

Closed developeruzairsaleem closed 7 months ago

developeruzairsaleem commented 7 months ago

Summary

Hey I found this typo on docs under GetStarted/Installation/using Typescript page under the "useReducer" section, the code includes ";" but it should be ","

Page

https://react.dev/learn/typescript

Details

Hey I found this typo on docs under GetStarted/Installation/using Typescript page under the "useReducer" section, the code includes ";" but it should be "," The code is written as follows type CounterAction = | { type: "reset" } | { type: "setCount"; value: State["count"] }

With ";" in object it should be a "," after the type:"setCount" The updated code should look like this type CounterAction = | { type: "reset" } | { type: "setCount", value: State["count"] } Thanks.

pwbriggs commented 7 months ago

Hey there, @developeruzairsaleem! 👋

The line you're referring to is not an object, it is an object type. In TypeScript, ; or , can be used in object types, and many codebases opt to use a semicolon to help differentiate the object type from an actual object.

developeruzairsaleem commented 7 months ago

Thanks By the way.