Commit ef53aea
committed
🐛 Avoid emitting
Consider an empty emitter function:
```ts
@component
class MyComponent {
@emit
public foo(): void {}
}
```
We would expect this to emit a `'foo'` event with no arguments (since
the return value is `undefined`).
However, when testing with `@vue/test-utils`, we have to write:
```ts
expect(component.emitted('foo')).to.eql([[undefined]])
```
But it would be nicer - and more consistent with
[`vue-property-decorator`][1] - if we instead called `$emit()` with no
arguments in this case to be able to write:
```ts
expect(component.emitted('foo')).to.eql([[]])
```
[1]: https://github.com/kaorun343/vue-property-decorator/blob/e04872349bab357e6d08b01442f83abc9976eb50/src/decorators/Emit.ts#L22undefined as a return value1 parent 53ec0ac commit ef53aea
2 files changed
+13
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
| |||
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
76 | 85 | | |
77 | 86 | | |
78 | | - | |
| 87 | + | |
0 commit comments