Skip to content

Commit ebf2afe

Browse files
authored
Merge pull request #2885 from sahandsn/patch-10
Update part9d.md
2 parents 3e6b922 + 2d36aa3 commit ebf2afe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/content/9/en/part9d.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ We can now set the data in the state *notes* to get the code working:
913913
914914
So just like with *useState*, we gave a type parameter to *axios.get* to instruct it how the typing should be done. Just like *useState* also *axios.get* is a [generic function](https://www.typescriptlang.org/docs/handbook/2/generics.html#working-with-generic-type-variables). Unlike some generic functions, the type parameter of *axios.get* has a default value *any* so, if the function is used without defining the type parameter, the type of the response data will be any.
915915
916-
The code works, compiler and Eslint are happy and remain quiet. However, giving a type parameter to *axios.get* is a potentially dangerous thing to do. The request body can contain data in an arbitrary form, and when giving a type parameter we are essentially just telling to TypeScript compiler to trust us that the data has type *Note[]*.
916+
The code works, compiler and Eslint are happy and remain quiet. However, giving a type parameter to *axios.get* is a potentially dangerous thing to do. The response body can contain data in an arbitrary form, and when giving a type parameter we are essentially just telling to TypeScript compiler to trust us that the data has type *Note[]*.
917917
918918
So our code is essentially as safe as it would be if a [type assertion](/en/part9/first_steps_with_type_script#type-assertion) would be used:
919919

0 commit comments

Comments
 (0)