Skip to content

Commit

Permalink
Merge pull request #42 from rimbu-org/feature/typescript_4_5
Browse files Browse the repository at this point in the history
Feature/typescript 4 5
  • Loading branch information
vitoke committed Nov 20, 2021
2 parents f99e37e + 915f9f2 commit 4184e49
Show file tree
Hide file tree
Showing 285 changed files with 5,033 additions and 7,087 deletions.
1 change: 0 additions & 1 deletion config/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true,
"noStrictGenericChecks": true,
"baseUrl": "./",
"isolatedModules": true,
"importsNotUsedAsValues": "error"
Expand Down
1 change: 0 additions & 1 deletion config/tsconfig.main.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true,
"noStrictGenericChecks": true,
"baseUrl": "./",
"isolatedModules": true,
"importsNotUsedAsValues": "error",
Expand Down
1 change: 0 additions & 1 deletion config/tsconfig.module.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true,
"noStrictGenericChecks": true,
"baseUrl": "./",
"isolatedModules": true,
"importsNotUsedAsValues": "error",
Expand Down
1 change: 0 additions & 1 deletion config/tsconfig.types.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true,
"noStrictGenericChecks": true,
"baseUrl": "./",
"isolatedModules": true,
"importsNotUsedAsValues": "error",
Expand Down
13 changes: 0 additions & 13 deletions deno_dist/actor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,6 @@ Running your script then becomes:

> `deno run --no-check --config tsconfig.json <your-script>.ts`
## Recommended `tsconfig.json` settings

Rimbu uses advanced and recursive typing, potentially making the TS compiler quite slow. It is recommended to set the following values in the `tsconfig.json` file of your project:

```json
{
"compilerOptions": {
"skipLibCheck": true,
"noStrictGenericChecks": true
}
}
```

## Usage

```ts
Expand Down
26 changes: 14 additions & 12 deletions deno_dist/actor/obs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class NotifierBase<T> {
}
}

class Impl<T, D> extends NotifierBase<Immutable<T & D>> implements Obs<T, D> {
class Impl<T, D> extends NotifierBase<Immutable<T & D>> {
//implements Obs<T, D> {
constructor(
public pureState: T,
readonly options?: {
Expand Down Expand Up @@ -137,7 +138,7 @@ class Impl<T, D> extends NotifierBase<Immutable<T & D>> implements Obs<T, D> {
}
): Obs.Readonly<T2 & D2> {
const onFirstSubscription = (): Obs.UnsubscribeFn => {
const unsubscribe1 = this.subscribe((newState) =>
const unsubscribe1 = this.subscribe((newState: Immutable<T & D>) =>
result.setState(mapTo(newState))
);
const unsubscribe2 = options?.onFirstSubscription?.();
Expand Down Expand Up @@ -174,7 +175,7 @@ class Impl<T, D> extends NotifierBase<Immutable<T & D>> implements Obs<T, D> {
}
): Obs<T2, D2> {
const onFirstSubscription = (): Obs.UnsubscribeFn => {
const unsubscribe1 = this.subscribe((newState) => {
const unsubscribe1 = this.subscribe((newState: Immutable<T & D>) => {
result.setState(mapTo(newState));
});
const unsubscribe2 = options?.onFirstSubscription?.();
Expand All @@ -200,7 +201,7 @@ class Impl<T, D> extends NotifierBase<Immutable<T & D>> implements Obs<T, D> {
},
});

return result;
return result as any;
}

select<P extends Path<T>, DR = unknown>(
Expand All @@ -214,13 +215,14 @@ class Impl<T, D> extends NotifierBase<Immutable<T & D>> implements Obs<T, D> {
onFirstSubscription?: () => Obs.UnsubscribeFn;
}
): Obs<Path.Result<T, P>, DR> {
return this.map(
(newParentState) => Path.getValue(newParentState as T, pathInState),
return this.map<Path.Result<T, P>, DR>(
(newParentState: Immutable<T & D>) =>
Path.getValue(newParentState as T, pathInState),
(newChildState: Immutable<Path.Result<T, P>>): Patch<T> => {
const pathObj = {};
const parts = pathInState.split('.');

if (parts.length <= 0) return Literal.of(newChildState);
if (parts.length <= 0) return Literal.of(newChildState) as any;

const lastPart = parts.pop()!;

Expand Down Expand Up @@ -250,7 +252,7 @@ class Impl<T, D> extends NotifierBase<Immutable<T & D>> implements Obs<T, D> {
onFirstSubscription?: () => Obs.UnsubscribeFn;
}
): Obs.Readonly<Path.Result<T & D, P> & DR> {
return this.mapReadonly(
return this.mapReadonly<Path.Result<T & D, P>, DR>(
(newParentState: Immutable<T & D>) =>
Path.getValue(newParentState as T & D, pathInState),
options
Expand All @@ -270,7 +272,7 @@ class Impl<T, D> extends NotifierBase<Immutable<T & D>> implements Obs<T, D> {
}
): Obs.Readonly<R & DR> {
const onFirstSubscription = (): Obs.UnsubscribeFn => {
const unsubscribe1 = this.subscribe((newState) => {
const unsubscribe1 = this.subscribe((newState: Immutable<T & D>) => {
result.setState(mapTo(newState, other.state));
});
const unsubscribe2 = other.subscribe((newState) => {
Expand Down Expand Up @@ -310,7 +312,7 @@ class Impl<T, D> extends NotifierBase<Immutable<T & D>> implements Obs<T, D> {
}
): Obs<R> {
const onFirstSubscription = (): Obs.UnsubscribeFn => {
const unsubscribe1 = this.subscribe((newState) => {
const unsubscribe1 = this.subscribe((newState: Immutable<T & D>) => {
result.setState(mapTo(newState, other.state));
});
const unsubscribe2 = other.subscribe((newState) => {
Expand Down Expand Up @@ -346,7 +348,7 @@ class Impl<T, D> extends NotifierBase<Immutable<T & D>> implements Obs<T, D> {
},
});

return result;
return result as any;
}
}

Expand Down Expand Up @@ -785,6 +787,6 @@ export namespace Obs {
onFirstSubscription?: () => Obs.UnsubscribeFn;
}
): Obs<T, D> {
return new Impl<T, D>(initState, options);
return new Impl<T, D>(initState, options) as any;
}
}
13 changes: 0 additions & 13 deletions deno_dist/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ Running your script then becomes:

> `deno run --no-check --config tsconfig.json <your-script>.ts`
## Recommended `tsconfig.json` settings

Rimbu uses advanced and recursive typing, potentially making the TypeScript compiler quite slow in some cases, or causing infinite recursion. It is recommended to set the following values in the `tsconfig.json` file of your project:

```json
{
"compilerOptions": {
"skipLibCheck": true,
"noStrictGenericChecks": true
}
}
```

## Usage

```ts
Expand Down
13 changes: 0 additions & 13 deletions deno_dist/bimap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ Running your script then becomes:

> `deno run --no-check --config tsconfig.json <your-script>.ts`
## Recommended `tsconfig.json` settings

Rimbu uses advanced and recursive typing, potentially making the TypeScript compiler quite slow in some cases, or causing infinite recursion. It is recommended to set the following values in the `tsconfig.json` file of your project:

```json
{
"compilerOptions": {
"skipLibCheck": true,
"noStrictGenericChecks": true
}
}
```

## Usage

```ts
Expand Down
59 changes: 28 additions & 31 deletions deno_dist/bimap/interface/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,26 +133,27 @@ export interface BiMap<K, V> extends FastIterable<readonly [K, V]> {
* // => [[1, 2]]
* @note if the key and/or value are already associated, the previous value will be 'replaced'
*/
set: (key: K, value: V) => BiMap.NonEmpty<K, V>;
set(key: K, value: V): BiMap.NonEmpty<K, V>;
/**
* Returns the collection with given `entry` added.
* @param entry - a tuple containing a key and value
* @example
* BiMap.of([1, 1], [2, 2]).addEntry([1, 2]).toArray()
* // => [[1, 2]]
*/
addEntry: (entry: readonly [K, V]) => BiMap.NonEmpty<K, V>;
addEntry(entry: readonly [K, V]): BiMap.NonEmpty<K, V>;
/**
* Returns the collection with the entries from the given `StreamSource` `entries` added.
* @param entries - a `StreamSource` containing tuples with a key and value
* @example
* BiMap.of([1, 1]).addEntries([[2, 2], [1, 3]]).toArray()
* // => [[1, 3], [2, 2]]
*/
addEntries: {
(entries: StreamSource.NonEmpty<readonly [K, V]>): BiMap.NonEmpty<K, V>;
(entries: StreamSource<readonly [K, V]>): BiMap<K, V>;
};
addEntries(
entries: StreamSource.NonEmpty<readonly [K, V]>
): BiMap.NonEmpty<K, V>;
addEntries(entries: StreamSource<readonly [K, V]>): BiMap<K, V>;

/**
* Returns the collection where the entry associated with given `key` is removed if it was part of the collection.
* @param key - the key of the entry to remove
Expand Down Expand Up @@ -302,7 +303,7 @@ export interface BiMap<K, V> extends FastIterable<readonly [K, V]> {
* @example
* const builder: BiMap.Builder<number, string> = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
*/
toBuilder: () => BiMap.Builder<K, V>;
toBuilder(): BiMap.Builder<K, V>;
/**
* Returns an array containing all entries in this collection.
* @example
Expand Down Expand Up @@ -380,9 +381,7 @@ export namespace BiMap {
* BiMap.of([1, 1]).addEntries([[2, 2], [1, 3]]).toArray()
* // => [[1, 2]]
*/
addEntries: (
entries: StreamSource<readonly [K, V]>
) => BiMap.NonEmpty<K, V>;
addEntries(entries: StreamSource<readonly [K, V]>): BiMap.NonEmpty<K, V>;
/**
* Returns the collection where the value associated with given `key` is updated with the given `update` value or update function.
* @param key - the key of the entry to update
Expand Down Expand Up @@ -467,36 +466,34 @@ export namespace BiMap {
* BiMap.empty<number, string>() // => BiMap<number, string>
* BiMap.empty<string, boolean>() // => BiMap<string, boolean>
*/
empty: <K extends UK, V extends UV>() => BiMap<K, V>;
empty<K extends UK, V extends UV>(): BiMap<K, V>;
/**
* Returns an immutable `BiMap`, containing the given `entries`.
* @param entries - a non-empty array of key-value entries
* @example
* BiMap.of([1, 'a'], [2, 'b']) // => BiMap.NonEmpty<number, string>
*/
of: <K extends UK, V extends UV>(
of<K extends UK, V extends UV>(
...entries: ArrayNonEmpty<readonly [K, V]>
) => BiMap.NonEmpty<K, V>;
): BiMap.NonEmpty<K, V>;
/**
* Returns an immutable BiMap, containing the entries in the given `sources` `StreamSource` instances.
* @param sources - an array of `StreamSource` instances contaning key-value entries
* @example
* BiMap.from([[1, 'a'], [2, 'b']]) // => BiMap.NonEmpty<number, string>
*/
from: {
<K extends UK, V extends UV>(
...sources: ArrayNonEmpty<StreamSource<readonly [K, V]>>
): BiMap.NonEmpty<K, V>;
<K extends UK, V extends UV>(
...sources: ArrayNonEmpty<StreamSource.NonEmpty<readonly [K, V]>>
): BiMap<K, V>;
};
from<K extends UK, V extends UV>(
...sources: ArrayNonEmpty<StreamSource<readonly [K, V]>>
): BiMap.NonEmpty<K, V>;
from<K extends UK, V extends UV>(
...sources: ArrayNonEmpty<StreamSource.NonEmpty<readonly [K, V]>>
): BiMap<K, V>;
/**
* Returns an empty `BiMap` builder instance.
* @example
* BiMap.builder<number, string>() // => BiMap.Builder<number, string>
*/
builder: <K extends UK, V extends UV>() => BiMap.Builder<K, V>;
builder<K extends UK, V extends UV>(): BiMap.Builder<K, V>;
/**
* Returns a `Reducer` that adds received tuples to a BiMap and returns the BiMap as a result. When a `source` is given,
* the reducer will first create a BiMap from the source, and then add tuples to it.
Expand All @@ -507,16 +504,16 @@ export namespace BiMap {
* result.toArray() // => [[1, 'c'], [2, 'b'], [3, 'a']]
* @note uses a builder under the hood. If the given `source` is a BiMap in the same context, it will directly call `.toBuilder()`.
*/
reducer: <K extends UK, V extends UV>(
reducer<K extends UK, V extends UV>(
source?: StreamSource<readonly [K, V]>
) => Reducer<readonly [K, V], BiMap<K, V>>;
): Reducer<readonly [K, V], BiMap<K, V>>;
}

export interface Types extends CustomBase.KeyValue {
normal: BiMap<this['_K'], this['_V']>;
nonEmpty: BiMap.NonEmpty<this['_K'], this['_V']>;
limitKey: true;
limitValue: true;
readonly normal: BiMap<this['_K'], this['_V']>;
readonly nonEmpty: BiMap.NonEmpty<this['_K'], this['_V']>;
readonly limitKey: true;
readonly limitValue: true;
}

/**
Expand Down Expand Up @@ -593,7 +590,7 @@ export namespace BiMap {
* m.set(1, 'a') // => false
* m.set(1, 'b') // => true
*/
set: (key: K, value: V) => boolean;
set(key: K, value: V): boolean;
/**
* Adds the given `entry` to the builder, where the entry key is associated with the entry value.
* @param entry - the entry to add
Expand All @@ -603,7 +600,7 @@ export namespace BiMap {
* m.addEntry([1, 'a']) // => false
* m.addEntry([1, 'b']) // => true
*/
addEntry: (entry: readonly [K, V]) => boolean;
addEntry(entry: readonly [K, V]): boolean;
/**
* Adds given `entries` to the builder.
* @param entries - a `StreamSource` containing the entries to add
Expand All @@ -613,7 +610,7 @@ export namespace BiMap {
* m.addEntries([1, 'a'], [3, 'c']]) // => true
* m.addEntries([]) // => false
*/
addEntries: (entries: StreamSource<readonly [K, V]>) => boolean;
addEntries(entries: StreamSource<readonly [K, V]>): boolean;
/**
* Removes the entries related to given `key` from the builder.
* @param key - the key to remove
Expand Down
13 changes: 0 additions & 13 deletions deno_dist/bimultimap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ Running your script then becomes:

> `deno run --no-check --config tsconfig.json <your-script>.ts`
## Recommended `tsconfig.json` settings

Rimbu uses advanced and recursive typing, potentially making the TypeScript compiler quite slow in some cases, or causing infinite recursion. It is recommended to set the following values in the `tsconfig.json` file of your project:

```json
{
"compilerOptions": {
"skipLibCheck": true,
"noStrictGenericChecks": true
}
}
```

## Usage

```ts
Expand Down
6 changes: 4 additions & 2 deletions deno_dist/bimultimap/implementation/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import {
} from '../bimultimap-custom.ts';

export interface ContextTypesImpl extends BiMultiMapBase.Types {
context: BiMultiMapContext<this['_K'], this['_V'], string, this>;
readonly context: BiMultiMapContext<this['_K'], this['_V'], string>;
}

export class BiMultiMapContext<
UK,
UV,
N extends string,
Tp extends ContextTypesImpl
Tp extends ContextTypesImpl = ContextTypesImpl
> implements BiMultiMapBase.Context<UK, UV, Tp>
{
constructor(
Expand All @@ -34,6 +34,8 @@ export class BiMultiMapContext<
>['valueKeyMultiMapContext']
) {}

readonly _fixTypes!: any;

get _types(): Tp {
return undefined as any;
}
Expand Down

0 comments on commit 4184e49

Please sign in to comment.