Skip to content

Commit 91103f7

Browse files
author
Arvid Nicolaas
committed
fix: ensure type predicates are typed according to new rules of TypeScript 5.5.2
1 parent a7d598f commit 91103f7

File tree

111 files changed

+287
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+287
-97
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ lerna-debug.log
1515
**/.DS_Store
1616

1717
.nx
18+
19+
**/_cjs_prepare/*

deno_dist/actor/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [0.15.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
**Note:** Version bump only for package @rimbu/actor
9+
610
# [0.15.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-02-14)
711

812
### Features

deno_dist/base/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
**Note:** Version bump only for package @rimbu/base
9+
610
# [2.0.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-01-26)
711

812
### Features

deno_dist/bimap/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [2.0.2](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
**Note:** Version bump only for package @rimbu/bimap
9+
610
## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-02-14)
711

812
**Note:** Version bump only for package @rimbu/bimap

deno_dist/bimap/custom/implementation/immutable.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export class BiMapEmpty<K = any, V = any>
1818
extends EmptyBase
1919
implements BiMap<K, V>
2020
{
21+
_NonEmptyType!: BiMap.NonEmpty<K, V>;
22+
2123
constructor(readonly context: BiMapContext<K, V>) {
2224
super();
2325
}
@@ -126,6 +128,8 @@ export class BiMapNonEmptyImpl<K, V>
126128
extends NonEmptyBase<readonly [K, V]>
127129
implements BiMap.NonEmpty<K, V>
128130
{
131+
_NonEmptyType!: BiMap.NonEmpty<K, V>;
132+
129133
constructor(
130134
readonly context: BiMapContext<K, V>,
131135
readonly keyValueMap: RMap.NonEmpty<K, V>,

deno_dist/bimap/main/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ export namespace BiMap {
424424
* BiMap.of([1, 1], [2, 2]).nonEmpty() // => true
425425
* ```
426426
*/
427-
nonEmpty(): true;
427+
nonEmpty(): this is BiMap.NonEmpty<K, V>;
428428
/**
429429
* Returns a self reference since this collection is known to be non-empty.
430430
* @example

deno_dist/bimultimap/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [2.1.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
### Features
9+
10+
- **stream:** improve typings and add new methods to (async)stream and (async)reducer ([02b094b](https://github.com/rimbu-org/rimbu/commit/02b094b8c361ed97e11b4d7c4206ce17d4eaa85b))
11+
612
## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-02-14)
713

814
**Note:** Version bump only for package @rimbu/bimultimap

deno_dist/bimultimap/custom/implementation/immutable.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export class BiMultiMapEmpty<K, V, Tp extends ContextTypesImpl>
1515
extends EmptyBase
1616
implements BiMultiMapBase<K, V, Tp>
1717
{
18+
_NonEmptyType!: WithKeyValue<Tp, K, V>['nonEmpty'];
19+
1820
constructor(readonly context: WithKeyValue<Tp, K, V>['context']) {
1921
super();
2022
}
@@ -136,6 +138,8 @@ export class BiMultiMapNonEmpty<
136138
extends NonEmptyBase<[K, V]>
137139
implements BiMultiMapBase.NonEmpty<K, V, Tp>
138140
{
141+
_NonEmptyType!: TpG['nonEmpty'];
142+
139143
constructor(
140144
readonly context: WithKeyValue<Tp, K, V>['context'],
141145
readonly keyValueMultiMap: TpG['keyValueMultiMapNonEmpty'],

deno_dist/bimultimap/custom/interface/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ export namespace BiMultiMapBase {
485485
* HashBiMultiMap.of([1, 1], [2, 2]).nonEmpty() // => true
486486
* ```
487487
*/
488-
nonEmpty(): true;
488+
nonEmpty(): this is WithKeyValue<Tp, K, V>['nonEmpty'];
489489
/**
490490
* Returns the collection with the entries from the given `StreamSource` `entries` added.
491491
* @param entries - a `StreamSource` containing tuples with a key and value

deno_dist/channel/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [0.3.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
**Note:** Version bump only for package @rimbu/channel
9+
610
# [0.3.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-02-14)
711

812
### Features

deno_dist/collection-types/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [2.1.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
**Note:** Version bump only for package @rimbu/collection-types
9+
610
# [2.1.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-02-14)
711

812
### Features

deno_dist/collection-types/common/base.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { RimbuError } from '../../base/mod.ts';
22
import { type FastIterable, type FastIterator, Stream } from '../../stream/mod.ts';
33

44
export abstract class EmptyBase {
5+
readonly _NonEmptyType: unknown;
6+
57
[Symbol.iterator](): FastIterator<any> {
68
return Stream.empty()[Symbol.iterator]();
79
}
@@ -26,7 +28,7 @@ export abstract class EmptyBase {
2628
return true;
2729
}
2830

29-
nonEmpty(): false {
31+
nonEmpty(): this is this['_NonEmptyType'] {
3032
return false;
3133
}
3234

@@ -48,6 +50,8 @@ export abstract class EmptyBase {
4850
}
4951

5052
export abstract class NonEmptyBase<E> implements FastIterable<E> {
53+
readonly _NonEmptyType: unknown;
54+
5155
abstract stream(): Stream.NonEmpty<E>;
5256

5357
[Symbol.iterator](): FastIterator<E> {
@@ -58,7 +62,7 @@ export abstract class NonEmptyBase<E> implements FastIterable<E> {
5862
return false;
5963
}
6064

61-
nonEmpty(): true {
65+
nonEmpty(): this is this['_NonEmptyType'] {
6266
return true;
6367
}
6468

deno_dist/collection-types/map-custom/interface/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export namespace VariantMapBase {
263263
* HashMap.of([1, 1], [2, 2]).nonEmpty() // => true
264264
* ```
265265
*/
266-
nonEmpty(): true;
266+
nonEmpty(): this is WithKeyValue<Tp, K, V>['nonEmpty'];
267267
/**
268268
* Returns a self reference since this collection is known to be non-empty.
269269
* @example

deno_dist/collection-types/set-custom/interface/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export namespace VariantSetBase {
210210
* HashSet.of(1, 2, 3).nonEmpty() // => true
211211
* ```
212212
*/
213-
nonEmpty(): true;
213+
nonEmpty(): this is WithElem<Tp, T>['nonEmpty'];
214214
/**
215215
* Returns a self reference since this collection is known to be non-empty.
216216
* @example

deno_dist/common/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
**Note:** Version bump only for package @rimbu/common
9+
610
# [2.0.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-01-26)
711

812
### Features

deno_dist/core/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [2.0.2](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
**Note:** Version bump only for package @rimbu/core
9+
610
## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-02-14)
711

812
**Note:** Version bump only for package @rimbu/core

deno_dist/deep/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
**Note:** Version bump only for package @rimbu/deep
9+
610
# [2.0.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-01-26)
711

812
### Features

deno_dist/graph/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [2.0.2](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
**Note:** Version bump only for package @rimbu/graph
9+
610
## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-02-14)
711

812
**Note:** Version bump only for package @rimbu/graph

deno_dist/graph/custom/common/interface/variant-graph-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export namespace VariantGraphBase {
281281
* ArrowGraphHashed.of([1], [2, 3]).nonEmpty() // => true
282282
* ```
283283
*/
284-
nonEmpty(): true;
284+
nonEmpty(): this is WithGraphValues<Tp, N, V>['nonEmpty'];
285285
/**
286286
* Returns this collection typed as a 'possibly empty' collection.
287287
* @example

deno_dist/graph/custom/non-valued/implementation/empty.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export class GraphEmpty<
1515
extends GraphEmptyBase
1616
implements GraphBase<N, Tp>
1717
{
18+
_NonEmptyType!: TpG['nonEmpty'];
19+
1820
constructor(readonly isDirected: boolean, readonly context: TpG['context']) {
1921
super();
2022
}

deno_dist/graph/custom/non-valued/implementation/non-empty.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export class GraphNonEmpty<
1919
extends NonEmptyBase<GraphElement<N>>
2020
implements GraphBase.NonEmpty<N, Tp>
2121
{
22+
_NonEmptyType!: TpG['nonEmpty'];
23+
2224
constructor(
2325
readonly isDirected: boolean,
2426
readonly context: TpG['context'],

deno_dist/graph/custom/valued/implementation/empty.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export class ValuedGraphEmpty<
1919
extends GraphEmptyBase
2020
implements ValuedGraphBase<N, V, Tp>
2121
{
22+
_NonEmptyType!: TpG['nonEmpty'];
23+
2224
constructor(readonly isDirected: boolean, readonly context: TpG['context']) {
2325
super();
2426
}

deno_dist/graph/custom/valued/implementation/non-empty.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export class ValuedGraphNonEmpty<
3030
extends NonEmptyBase<ValuedGraphElement<N, V>>
3131
implements ValuedGraphBase.NonEmpty<N, V, Tp>
3232
{
33+
_NonEmptyType!: TpG['nonEmpty'];
34+
3335
constructor(
3436
readonly isDirected: boolean,
3537
readonly context: TpG['context'],

deno_dist/hashed/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [2.1.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
**Note:** Version bump only for package @rimbu/hashed
9+
610
# [2.1.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-02-14)
711

812
### Features

deno_dist/hashed/map-custom/implementation/immutable.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export class HashMapEmpty<K = any, V = any>
2020
extends EmptyBase
2121
implements HashMap<K, V>
2222
{
23+
_NonEmptyType!: HashMap.NonEmpty<K, V>;
24+
2325
constructor(readonly context: HashMapContext<K>) {
2426
super();
2527
}
@@ -108,6 +110,8 @@ export abstract class HashMapNonEmptyBase<K, V>
108110
extends NonEmptyBase<readonly [K, V]>
109111
implements HashMap.NonEmpty<K, V>
110112
{
113+
_NonEmptyType!: HashMap.NonEmpty<K, V>;
114+
111115
abstract get context(): HashMapContext<K>;
112116
abstract get size(): number;
113117
abstract get<UK, O>(key: RelatedTo<K, UK>, otherwise?: OptLazy<O>): V | O;

deno_dist/hashed/set-custom/implementation/immutable.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import type { HashSet } from '../../../hashed/set/index.ts';
1414
import type { HashSetContext } from '../../../hashed/set-custom/index.ts';
1515

1616
export class HashSetEmpty<T = any> extends EmptyBase implements HashSet<T> {
17+
_NonEmptyType!: HashSet.NonEmpty<T>;
18+
1719
readonly addAll: any;
1820

1921
constructor(readonly context: HashSetContext<T>) {
@@ -81,6 +83,8 @@ export abstract class HashSetNonEmptyBase<T>
8183
extends NonEmptyBase<T>
8284
implements HashSet.NonEmpty<T>
8385
{
86+
_NonEmptyType!: HashSet.NonEmpty<T>;
87+
8488
abstract get context(): HashSetContext<T>;
8589
abstract get size(): number;
8690
abstract stream(): Stream.NonEmpty<T>;

deno_dist/list/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [2.1.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
**Note:** Version bump only for package @rimbu/list
9+
610
# [2.1.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-02-14)
711

812
### Features

deno_dist/list/custom/implementation/empty.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import type { List } from '../../../list/mod.ts';
66
import type { ListContext } from '../../../list/custom/index.ts';
77

88
export class Empty<T = any> extends EmptyBase implements List<T> {
9+
_NonEmptyType!: List.NonEmpty<T>;
10+
911
constructor(readonly context: ListContext) {
1012
super();
1113
}

deno_dist/list/custom/implementation/leaf/non-empty.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export abstract class ListNonEmptyBase<T>
6868
return false;
6969
}
7070

71-
nonEmpty(): true {
71+
nonEmpty(): this is List.NonEmpty<T> {
7272
return true;
7373
}
7474

deno_dist/list/main/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ export namespace List {
613613
* List.of(0, 1, 2).nonEmpty() // => true
614614
* ```
615615
*/
616-
nonEmpty(): true;
616+
nonEmpty(): this is List.NonEmpty<T>;
617617
/**
618618
* Returns a self reference since this collection is known to be non-empty.
619619
* @example

deno_dist/multimap/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [2.1.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-03-05)
7+
8+
### Features
9+
10+
- **stream:** improve typings and add new methods to (async)stream and (async)reducer ([02b094b](https://github.com/rimbu-org/rimbu/commit/02b094b8c361ed97e11b4d7c4206ce17d4eaa85b))
11+
612
## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2024-02-14)
713

814
**Note:** Version bump only for package @rimbu/multimap

deno_dist/multimap/custom/implementation/base.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export class MultiMapEmpty<K, V, Tp extends ContextImplTypes>
2727
extends EmptyBase
2828
implements MultiMapBase<K, V, Tp>
2929
{
30+
_NonEmptyType!: WithKeyValue<Tp, K, V>['nonEmpty'];
31+
3032
constructor(readonly context: WithKeyValue<Tp, K, V>['context']) {
3133
super();
3234
}
@@ -143,6 +145,8 @@ export class MultiMapNonEmpty<
143145
extends NonEmptyBase<[K, V]>
144146
implements MultiMapBase.NonEmpty<K, V, Tp>
145147
{
148+
_NonEmptyType!: TpG['nonEmpty'];
149+
146150
constructor(
147151
readonly context: TpG['context'],
148152
readonly keyMap: TpG['keyMapNonEmpty'],

deno_dist/multimap/custom/interface/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ export namespace VariantMultiMapBase {
347347
* HashMultiMapHashValue.of([1, 1], [2, 2]).nonEmpty() // => true
348348
* ```
349349
*/
350-
nonEmpty(): true;
350+
nonEmpty(): this is WithKeyValue<Tp, K, V>['nonEmpty'];
351351
/**
352352
* Returns a non-empty Stream containing all entries of this collection as tuples of key and value.
353353
* @example

0 commit comments

Comments
 (0)