Skip to content

Commit

Permalink
Merge pull request #229 from rimbu-org/feature/fix-ts-52-type-predicates
Browse files Browse the repository at this point in the history
fix: ensure type predicates are typed according to new rules of TypeScript 5.5.2
  • Loading branch information
vitoke authored Jun 28, 2024
2 parents a7d598f + 91103f7 commit b5eda2f
Show file tree
Hide file tree
Showing 111 changed files with 287 additions and 97 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ lerna-debug.log
**/.DS_Store

.nx

**/_cjs_prepare/*
4 changes: 4 additions & 0 deletions deno_dist/actor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.15.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/actor@0.15.0...@rimbu/actor@0.15.1) (2024-03-05)

**Note:** Version bump only for package @rimbu/actor

# [0.15.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/actor@0.14.0...@rimbu/actor@0.15.0) (2024-02-14)

### Features
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/base/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/base@2.0.0...@rimbu/base@2.0.1) (2024-03-05)

**Note:** Version bump only for package @rimbu/base

# [2.0.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/base@1.1.0...@rimbu/base@2.0.0) (2024-01-26)

### Features
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/bimap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.0.2](https://github.com/rimbu-org/rimbu/compare/@rimbu/bimap@2.0.1...@rimbu/bimap@2.0.2) (2024-03-05)

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

## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/bimap@2.0.0...@rimbu/bimap@2.0.1) (2024-02-14)

**Note:** Version bump only for package @rimbu/bimap
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/bimap/custom/implementation/immutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class BiMapEmpty<K = any, V = any>
extends EmptyBase
implements BiMap<K, V>
{
_NonEmptyType!: BiMap.NonEmpty<K, V>;

constructor(readonly context: BiMapContext<K, V>) {
super();
}
Expand Down Expand Up @@ -126,6 +128,8 @@ export class BiMapNonEmptyImpl<K, V>
extends NonEmptyBase<readonly [K, V]>
implements BiMap.NonEmpty<K, V>
{
_NonEmptyType!: BiMap.NonEmpty<K, V>;

constructor(
readonly context: BiMapContext<K, V>,
readonly keyValueMap: RMap.NonEmpty<K, V>,
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/bimap/main/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export namespace BiMap {
* BiMap.of([1, 1], [2, 2]).nonEmpty() // => true
* ```
*/
nonEmpty(): true;
nonEmpty(): this is BiMap.NonEmpty<K, V>;
/**
* Returns a self reference since this collection is known to be non-empty.
* @example
Expand Down
6 changes: 6 additions & 0 deletions deno_dist/bimultimap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.1.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/bimultimap@2.0.1...@rimbu/bimultimap@2.1.0) (2024-03-05)

### Features

- **stream:** improve typings and add new methods to (async)stream and (async)reducer ([02b094b](https://github.com/rimbu-org/rimbu/commit/02b094b8c361ed97e11b4d7c4206ce17d4eaa85b))

## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/bimultimap@2.0.0...@rimbu/bimultimap@2.0.1) (2024-02-14)

**Note:** Version bump only for package @rimbu/bimultimap
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/bimultimap/custom/implementation/immutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export class BiMultiMapEmpty<K, V, Tp extends ContextTypesImpl>
extends EmptyBase
implements BiMultiMapBase<K, V, Tp>
{
_NonEmptyType!: WithKeyValue<Tp, K, V>['nonEmpty'];

constructor(readonly context: WithKeyValue<Tp, K, V>['context']) {
super();
}
Expand Down Expand Up @@ -136,6 +138,8 @@ export class BiMultiMapNonEmpty<
extends NonEmptyBase<[K, V]>
implements BiMultiMapBase.NonEmpty<K, V, Tp>
{
_NonEmptyType!: TpG['nonEmpty'];

constructor(
readonly context: WithKeyValue<Tp, K, V>['context'],
readonly keyValueMultiMap: TpG['keyValueMultiMapNonEmpty'],
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/bimultimap/custom/interface/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export namespace BiMultiMapBase {
* HashBiMultiMap.of([1, 1], [2, 2]).nonEmpty() // => true
* ```
*/
nonEmpty(): true;
nonEmpty(): this is WithKeyValue<Tp, K, V>['nonEmpty'];
/**
* Returns the collection with the entries from the given `StreamSource` `entries` added.
* @param entries - a `StreamSource` containing tuples with a key and value
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/channel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.3.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/channel@0.3.0...@rimbu/channel@0.3.1) (2024-03-05)

**Note:** Version bump only for package @rimbu/channel

# [0.3.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/channel@0.2.0...@rimbu/channel@0.3.0) (2024-02-14)

### Features
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/collection-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.1.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/collection-types@2.1.0...@rimbu/collection-types@2.1.1) (2024-03-05)

**Note:** Version bump only for package @rimbu/collection-types

# [2.1.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/collection-types@2.0.0...@rimbu/collection-types@2.1.0) (2024-02-14)

### Features
Expand Down
8 changes: 6 additions & 2 deletions deno_dist/collection-types/common/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { RimbuError } from '../../base/mod.ts';
import { type FastIterable, type FastIterator, Stream } from '../../stream/mod.ts';

export abstract class EmptyBase {
readonly _NonEmptyType: unknown;

[Symbol.iterator](): FastIterator<any> {
return Stream.empty()[Symbol.iterator]();
}
Expand All @@ -26,7 +28,7 @@ export abstract class EmptyBase {
return true;
}

nonEmpty(): false {
nonEmpty(): this is this['_NonEmptyType'] {
return false;
}

Expand All @@ -48,6 +50,8 @@ export abstract class EmptyBase {
}

export abstract class NonEmptyBase<E> implements FastIterable<E> {
readonly _NonEmptyType: unknown;

abstract stream(): Stream.NonEmpty<E>;

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

nonEmpty(): true {
nonEmpty(): this is this['_NonEmptyType'] {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion deno_dist/collection-types/map-custom/interface/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export namespace VariantMapBase {
* HashMap.of([1, 1], [2, 2]).nonEmpty() // => true
* ```
*/
nonEmpty(): true;
nonEmpty(): this is WithKeyValue<Tp, K, V>['nonEmpty'];
/**
* Returns a self reference since this collection is known to be non-empty.
* @example
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/collection-types/set-custom/interface/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export namespace VariantSetBase {
* HashSet.of(1, 2, 3).nonEmpty() // => true
* ```
*/
nonEmpty(): true;
nonEmpty(): this is WithElem<Tp, T>['nonEmpty'];
/**
* Returns a self reference since this collection is known to be non-empty.
* @example
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/common@2.0.0...@rimbu/common@2.0.1) (2024-03-05)

**Note:** Version bump only for package @rimbu/common

# [2.0.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/common@1.1.0...@rimbu/common@2.0.0) (2024-01-26)

### Features
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.0.2](https://github.com/rimbu-org/rimbu/compare/@rimbu/core@2.0.1...@rimbu/core@2.0.2) (2024-03-05)

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

## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/core@2.0.0...@rimbu/core@2.0.1) (2024-02-14)

**Note:** Version bump only for package @rimbu/core
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/deep/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/deep@2.0.0...@rimbu/deep@2.0.1) (2024-03-05)

**Note:** Version bump only for package @rimbu/deep

# [2.0.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/deep@1.1.0...@rimbu/deep@2.0.0) (2024-01-26)

### Features
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/graph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.0.2](https://github.com/rimbu-org/rimbu/compare/@rimbu/graph@2.0.1...@rimbu/graph@2.0.2) (2024-03-05)

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

## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/graph@2.0.0...@rimbu/graph@2.0.1) (2024-02-14)

**Note:** Version bump only for package @rimbu/graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export namespace VariantGraphBase {
* ArrowGraphHashed.of([1], [2, 3]).nonEmpty() // => true
* ```
*/
nonEmpty(): true;
nonEmpty(): this is WithGraphValues<Tp, N, V>['nonEmpty'];
/**
* Returns this collection typed as a 'possibly empty' collection.
* @example
Expand Down
2 changes: 2 additions & 0 deletions deno_dist/graph/custom/non-valued/implementation/empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export class GraphEmpty<
extends GraphEmptyBase
implements GraphBase<N, Tp>
{
_NonEmptyType!: TpG['nonEmpty'];

constructor(readonly isDirected: boolean, readonly context: TpG['context']) {
super();
}
Expand Down
2 changes: 2 additions & 0 deletions deno_dist/graph/custom/non-valued/implementation/non-empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export class GraphNonEmpty<
extends NonEmptyBase<GraphElement<N>>
implements GraphBase.NonEmpty<N, Tp>
{
_NonEmptyType!: TpG['nonEmpty'];

constructor(
readonly isDirected: boolean,
readonly context: TpG['context'],
Expand Down
2 changes: 2 additions & 0 deletions deno_dist/graph/custom/valued/implementation/empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export class ValuedGraphEmpty<
extends GraphEmptyBase
implements ValuedGraphBase<N, V, Tp>
{
_NonEmptyType!: TpG['nonEmpty'];

constructor(readonly isDirected: boolean, readonly context: TpG['context']) {
super();
}
Expand Down
2 changes: 2 additions & 0 deletions deno_dist/graph/custom/valued/implementation/non-empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export class ValuedGraphNonEmpty<
extends NonEmptyBase<ValuedGraphElement<N, V>>
implements ValuedGraphBase.NonEmpty<N, V, Tp>
{
_NonEmptyType!: TpG['nonEmpty'];

constructor(
readonly isDirected: boolean,
readonly context: TpG['context'],
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/hashed/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.1.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/hashed@2.1.0...@rimbu/hashed@2.1.1) (2024-03-05)

**Note:** Version bump only for package @rimbu/hashed

# [2.1.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/hashed@2.0.0...@rimbu/hashed@2.1.0) (2024-02-14)

### Features
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/hashed/map-custom/implementation/immutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export class HashMapEmpty<K = any, V = any>
extends EmptyBase
implements HashMap<K, V>
{
_NonEmptyType!: HashMap.NonEmpty<K, V>;

constructor(readonly context: HashMapContext<K>) {
super();
}
Expand Down Expand Up @@ -108,6 +110,8 @@ export abstract class HashMapNonEmptyBase<K, V>
extends NonEmptyBase<readonly [K, V]>
implements HashMap.NonEmpty<K, V>
{
_NonEmptyType!: HashMap.NonEmpty<K, V>;

abstract get context(): HashMapContext<K>;
abstract get size(): number;
abstract get<UK, O>(key: RelatedTo<K, UK>, otherwise?: OptLazy<O>): V | O;
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/hashed/set-custom/implementation/immutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type { HashSet } from '../../../hashed/set/index.ts';
import type { HashSetContext } from '../../../hashed/set-custom/index.ts';

export class HashSetEmpty<T = any> extends EmptyBase implements HashSet<T> {
_NonEmptyType!: HashSet.NonEmpty<T>;

readonly addAll: any;

constructor(readonly context: HashSetContext<T>) {
Expand Down Expand Up @@ -81,6 +83,8 @@ export abstract class HashSetNonEmptyBase<T>
extends NonEmptyBase<T>
implements HashSet.NonEmpty<T>
{
_NonEmptyType!: HashSet.NonEmpty<T>;

abstract get context(): HashSetContext<T>;
abstract get size(): number;
abstract stream(): Stream.NonEmpty<T>;
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/list/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.1.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/list@2.1.0...@rimbu/list@2.1.1) (2024-03-05)

**Note:** Version bump only for package @rimbu/list

# [2.1.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/list@2.0.0...@rimbu/list@2.1.0) (2024-02-14)

### Features
Expand Down
2 changes: 2 additions & 0 deletions deno_dist/list/custom/implementation/empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import type { List } from '../../../list/mod.ts';
import type { ListContext } from '../../../list/custom/index.ts';

export class Empty<T = any> extends EmptyBase implements List<T> {
_NonEmptyType!: List.NonEmpty<T>;

constructor(readonly context: ListContext) {
super();
}
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/list/custom/implementation/leaf/non-empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export abstract class ListNonEmptyBase<T>
return false;
}

nonEmpty(): true {
nonEmpty(): this is List.NonEmpty<T> {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion deno_dist/list/main/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ export namespace List {
* List.of(0, 1, 2).nonEmpty() // => true
* ```
*/
nonEmpty(): true;
nonEmpty(): this is List.NonEmpty<T>;
/**
* Returns a self reference since this collection is known to be non-empty.
* @example
Expand Down
6 changes: 6 additions & 0 deletions deno_dist/multimap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.1.0](https://github.com/rimbu-org/rimbu/compare/@rimbu/multimap@2.0.1...@rimbu/multimap@2.1.0) (2024-03-05)

### Features

- **stream:** improve typings and add new methods to (async)stream and (async)reducer ([02b094b](https://github.com/rimbu-org/rimbu/commit/02b094b8c361ed97e11b4d7c4206ce17d4eaa85b))

## [2.0.1](https://github.com/rimbu-org/rimbu/compare/@rimbu/multimap@2.0.0...@rimbu/multimap@2.0.1) (2024-02-14)

**Note:** Version bump only for package @rimbu/multimap
Expand Down
4 changes: 4 additions & 0 deletions deno_dist/multimap/custom/implementation/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export class MultiMapEmpty<K, V, Tp extends ContextImplTypes>
extends EmptyBase
implements MultiMapBase<K, V, Tp>
{
_NonEmptyType!: WithKeyValue<Tp, K, V>['nonEmpty'];

constructor(readonly context: WithKeyValue<Tp, K, V>['context']) {
super();
}
Expand Down Expand Up @@ -143,6 +145,8 @@ export class MultiMapNonEmpty<
extends NonEmptyBase<[K, V]>
implements MultiMapBase.NonEmpty<K, V, Tp>
{
_NonEmptyType!: TpG['nonEmpty'];

constructor(
readonly context: TpG['context'],
readonly keyMap: TpG['keyMapNonEmpty'],
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/multimap/custom/interface/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export namespace VariantMultiMapBase {
* HashMultiMapHashValue.of([1, 1], [2, 2]).nonEmpty() // => true
* ```
*/
nonEmpty(): true;
nonEmpty(): this is WithKeyValue<Tp, K, V>['nonEmpty'];
/**
* Returns a non-empty Stream containing all entries of this collection as tuples of key and value.
* @example
Expand Down
Loading

0 comments on commit b5eda2f

Please sign in to comment.