Skip to content

Commit d5c1704

Browse files
committed
Linter fixes
1 parent b4511bc commit d5c1704

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

docs/typescript.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Type assertions make the code brittle against changes. While TypeScript will thr
120120
##### To prevent or fix `any` usage
121121

122122
Unsafe as type assertions may be, they are still categorically preferable to using `any`.
123+
123124
- With type assertions, we still get working intellisense, autocomplete, and other IDE features.
124125
- Type assertions also provide an indication of the expected type as intended by the author.
125126
- For type assertions to an incompatible shape, use `as unknown as` as a last resort rather than `any` or `as any`.
@@ -131,6 +132,7 @@ Unsafe as type assertions may be, they are still categorically preferable to usi
131132
##### To type data objects whose shape and contents are determined at runtime
132133

133134
Preferably, this typing should be accompanied by schema validation performed with type guards and unit tests.
135+
134136
- e.g. The output of `JSON.parse()` or `await response.json()` for a known JSON input.
135137
- e.g. The type of a JSON file.
136138

@@ -139,6 +141,7 @@ Preferably, this typing should be accompanied by schema validation performed wit
139141
##### In tests, for mocking or to exclude irrelevant but required properties from an input object
140142

141143
<!-- TODO: Add examples -->
144+
142145
It's recommended to provide accurate typing if there's any chance that omitting properties affects the accuracy of the test.
143146

144147
Otherwise, only mocking the properties needed in the test improves readability by making the intention and scope of the mocking clear, not to mention being convenient to write.

0 commit comments

Comments
 (0)