Commit e20f1a8
refactor(cli): remove generic argument from
The `IIoHost` interface has the following method:
```ts
interface IIoHost {
notify<T>(msg: IoMessage<T>): Promise<void>;
}
```
The generic parameter `T` is only used once, without bounds, for a
singleton argument in input position. This means it is equivalent to the
following:
```ts
interface IIoHost {
notify(msg: IoMessage<unknown>): Promise<void>;
}
```
(Preferring `unknown` over `any` so that implementors are forced to test
for the type of the `data` field, just like they would need to do with
an argument of type `T`)
In the words of the [Java generics
tutorial](https://docs.oracle.com/javase/tutorial/extra/generics/methods.html):
> Generic methods allow type parameters to be used to express
> dependencies among the types of one or more arguments to a method
and/or
> its return type. If there isn't such a dependency, a generic method
> should not be used.
Or [similar advice for
TypeScript](https://effectivetypescript.com/2020/08/12/generics-golden-rule/):
> Type Parameters Should Appear Twice
>
> Type parameters are for relating the types of multiple values. If a
> type parameter is only used once in the function signature, it's not
> relating anything.
---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license
---------
Co-authored-by: Momo Kornher <[email protected]>notify<T>() (#217)1 parent db60595 commit e20f1a8
File tree
6 files changed
+11
-11
lines changed- packages
- @aws-cdk
- tmp-toolkit-helpers/src/api/io
- private
- toolkit-lib/test/_helpers
- aws-cdk
- lib
- cli/activity-printer
- toolkit
- test/_helpers
6 files changed
+11
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
379 | | - | |
| 379 | + | |
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
0 commit comments