@@ -123,7 +123,7 @@ I'll show examples of defining custom generics in a minute.
123
123
124
124
## The case for generics
125
125
126
- Let's say you need a another function to call a different endpoint,
126
+ Let's say you need another function to call a different endpoint,
127
127
this time to fetch user roles:
128
128
129
129
<pre class =" language-ts " >
@@ -246,7 +246,7 @@ This required a bit more code and we now have a
246
246
[ type constraint] ( https://www.typescriptlang.org/docs/handbook/generics.html#generic-constraints )
247
247
(via the ` extends ` keyword)
248
248
to denote the object shape.
249
- Specifically, we're saying ` request() ` takes a type variable ` <D> ` which
249
+ Specifically, we're saying ` request() ` takes a type variable ` D ` which
250
250
is an object having the keys ` BodyType ` and ` ResponseType ` .
251
251
252
252
Let's define a function to make a ` GET ` request:
@@ -286,14 +286,14 @@ with `any` types but there are still valid cases for them.
286
286
If you're converting a legacy code base to TypeScript,
287
287
falling back on ` any ` is a powerful way
288
288
to maintain forward momentum.
289
- Converting a large code base to TypeScript could take a long time .
289
+ Converting a large code base could take longer than you think .
290
290
It's a good investment but it still takes time away from shipping
291
291
product features so one often has to do it incrementally.
292
292
293
293
There are other powerful
294
294
[ escape hatches] ( https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html )
295
295
in TypeScript
296
- like ` @ts-ignore ` or ` @ts-nocheck ` .
296
+ like ` @ts-ignore ` and ` @ts-nocheck ` .
297
297
I'm a big fan of
298
298
[ spike, test, break, fix] ( http://farmdev.com/thoughts/113/spike-test-break-fix/ )
299
299
development.
@@ -317,13 +317,13 @@ for more details.
317
317
I also provided some lint rules to help keep a codebase safe as it evolves.
318
318
All of this has to be enforced with
319
319
[ continuous integration] ( http://farmdev.com/thoughts/114/if-it-s-not-in-ci-it-doesn-t-exist/ )
320
- to add lasting value to your team .
320
+ for it to add lasting value.
321
321
322
322
If you'd like to play around with these code examples,
323
323
I've made them
324
324
[ available] ( https://github.com/kumar303/safer-typescript-examples ) .
325
325
However, they are just examples.
326
- Rather than building a type safe API from scratch,
326
+ Rather than building a type safe API client from scratch,
327
327
check out
328
328
[ axios] ( https://github.com/axios/axios ) .
329
329
It supports TypeScript and is
0 commit comments