Skip to content

Commit 6eadc9d

Browse files
author
kz2d
committed
Fix: types for add-emitter and json/stream/streans
1 parent 6a58075 commit 6eadc9d

File tree

2 files changed

+12
-11
lines changed
  • src/core
    • cache/decorators/helpers/add-emitter
    • json/stream/streamers

2 files changed

+12
-11
lines changed

src/core/cache/decorators/helpers/add-emitter/spec.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* https://github.com/V4Fire/Core/blob/master/LICENSE
77
*/
88

9-
import addEmitter, { eventEmitter } from 'core/cache/decorators/helpers/add-emitter';
9+
import addEmitter, { CacheWithEmitter, eventEmitter } from 'core/cache/decorators/helpers/add-emitter';
1010

1111
import SimpleCache from 'core/cache/simple';
1212
import RestrictedCache from 'core/cache/restricted';
@@ -132,15 +132,16 @@ describe('core/cache/decorators/helpers/add-emitter', () => {
132132
it('sets a new value', () => {
133133
const
134134
cache = new SimpleCache(),
135-
{set} = addEmitter(cache);
135+
{set} = addEmitter(cache),
136+
cacheEmitter = <CacheWithEmitter><unknown>cache;
136137

137138
const memory: any[] = [];
138139

139-
cache[eventEmitter].on('set', (...args) => {
140+
cacheEmitter[eventEmitter].on('set', (...args) => {
140141
memory.push(args);
141142
});
142143

143-
cache.set('foo', 1, {ttl: 100, cacheTTL: 200});
144+
cacheEmitter.set('foo', 1, {ttl: 100, cacheTTL: 200});
144145
expect(memory[0]).toEqual([cache, {args: ['foo', 1, {ttl: 100, cacheTTL: 200}], result: 1}]);
145146

146147
set('bar', 2);

src/core/json/stream/streamers/spec.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import Parser from 'core/json/stream/parser';
1010

1111
import { Pick } from 'core/json/stream/filters';
12-
import { ArrayStreamer, ObjectStreamer } from 'core/json/stream/streamers';
12+
import { ArrayStreamer, ObjectStreamer, StreamedArray, StreamedObject } from 'core/json/stream/streamers';
1313

1414
describe('core/json/stream/streamers', () => {
1515
describe('`ArrayStreamer`', () => {
@@ -23,7 +23,7 @@ describe('core/json/stream/streamers', () => {
2323
}`;
2424

2525
const
26-
tokens = [];
26+
tokens: StreamedArray[] = [];
2727

2828
for await (const token of Parser.from([data], new Pick('a.b'), new ArrayStreamer())) {
2929
tokens.push(token);
@@ -39,7 +39,7 @@ describe('core/json/stream/streamers', () => {
3939

4040
it('should stream nothing if the source array is empty', async () => {
4141
const
42-
tokens = [];
42+
tokens: StreamedArray[] = [];
4343

4444
for await (const token of Parser.from(['[]'], new ArrayStreamer())) {
4545
tokens.push(token);
@@ -53,7 +53,7 @@ describe('core/json/stream/streamers', () => {
5353
err;
5454

5555
const
56-
tokens = [];
56+
tokens: StreamedArray[] = [];
5757

5858
try {
5959
for await (const token of Parser.from(['{"a": 1}'], new ArrayStreamer())) {
@@ -80,7 +80,7 @@ describe('core/json/stream/streamers', () => {
8080
}`;
8181

8282
const
83-
tokens = [];
83+
tokens: StreamedObject[] = [];
8484

8585
for await (const token of Parser.from([data], new ObjectStreamer())) {
8686
tokens.push(token);
@@ -94,7 +94,7 @@ describe('core/json/stream/streamers', () => {
9494

9595
it('should stream nothing if the source object is empty', async () => {
9696
const
97-
tokens = [];
97+
tokens: StreamedObject[] = [];
9898

9999
for await (const token of Parser.from(['{}'], new ObjectStreamer())) {
100100
tokens.push(token);
@@ -108,7 +108,7 @@ describe('core/json/stream/streamers', () => {
108108
err;
109109

110110
const
111-
tokens = [];
111+
tokens: StreamedObject[] = [];
112112

113113
try {
114114
for await (const token of Parser.from(['[1,2]'], new ObjectStreamer())) {

0 commit comments

Comments
 (0)