Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 12 support strict type import export ( fix for retrocompat ) #14

Merged
merged 3 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ The `Operator` type alias defines what functions qualify as a valid EVT operaor.
In `Operator<T, U>` , `T` design the type of the event data and `U` design the type of the data spitted out by the operator. For filters operator `U=T`.

```typescript
import { Operator } from "evt";
import type { Operator } from "evt";

//A function that take an EVT operator as argument.
declare function f<T, U>(op: Operator<T, U>): void;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { assert } from "../tools/typeSafety/assert";
import { typeGuard } from "../tools/typeSafety/typeGuard";
import { LazyEvt } from "./LazyEvt";
import { importProxy } from "./importProxy";
import { Handler } from "./types/Handler";
import type { Handler } from "./types/Handler";
import { defineAccessors } from "../tools/typeSafety/defineAccessors";
import { overwriteReadonlyProp } from "../tools/typeSafety/overwriteReadonlyProp";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/Evt.asNonPostable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { ToNonPostableEvt } from "./types/helper/ToNonPostableEvt";
import type { ToNonPostableEvt } from "./types/helper/ToNonPostableEvt";
type EvtLike<T>= import("./types/helper/UnpackEvt").EvtLike<T>;

/** https://docs.evt.land/api/evt/asnonpostable */
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Evt.asPostable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { ToPostableEvt } from "./types/helper/ToPostableEvt";
type EvtLike<T>= import("./types/helper/UnpackEvt").EvtLike<T>;
type ToPostableEvt<E extends ({ [key: string]: any; } | EvtLike<any>)> = import("./types/helper/ToPostableEvt").ToPostableEvt<E>;

/**
* https://docs.evt.land/api/evt/aspostable
Expand Down
8 changes: 6 additions & 2 deletions src/lib/Evt.asyncPipe.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

import { Evt } from "./Evt";
import { UnpackEvt } from "./types/helper/UnpackEvt";
import { SwapEvtType } from "./types/helper/SwapEvtType";

type UnpackEvt<T extends ({ [key: string]: any; } | import("./types/helper/UnpackEvt").EvtLike<any>)> =
import("./types/helper/UnpackEvt").UnpackEvt<T>;

type SwapEvtType<E extends import("./types/helper/UnpackEvt").EvtLike<any>, T> =
import("./types/helper/SwapEvtType").SwapEvtType<E, T>;

type EvtLike<T> = import("./types/helper/UnpackEvt").EvtLike<T> & {
attach(callback: (data: T) => void): void;
Expand Down
4 changes: 3 additions & 1 deletion src/lib/Evt.factorize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

import { FactorizeEvt } from "./types/helper/FactorizeEvt";

type FactorizeEvt<E extends import("./types/helper/UnpackEvt").EvtLike<any>> =
import("./types/helper/FactorizeEvt").FactorizeEvt<E>;

type EvtLike<T> = import("./types/helper/UnpackEvt").EvtLike<T>;

Expand Down
12 changes: 12 additions & 0 deletions src/lib/Evt.from.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ import { typeGuard } from "../tools/typeSafety/typeGuard";
import { EventTargetLike } from "./types/EventTargetLike";
import { mergeImpl } from "./Evt.merge";
import { importProxy } from "./importProxy";

import * as dom from "./types/lib.dom";

/*
namespace dom {

export type HTMLElementEventMap = import("./types/lib.dom").HTMLElementEventMap;
export type WindowEventMap = import("./types/lib.dom").WindowEventMap;
export type DocumentEventMap = import("./types/lib.dom").DocumentEventMap;

}
*/

type Evt<T>= import("./types/interfaces/Evt").Evt<T>;
type EvtLike<T> = import("./types/helper/UnpackEvt").EvtLike<T>;

Expand Down
8 changes: 6 additions & 2 deletions src/lib/Evt.loosenType.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { SwapEvtType } from "./types/helper/SwapEvtType";
import { UnpackEvt } from "./types/helper/UnpackEvt";

type SwapEvtType<E extends import("./types/helper/UnpackEvt").EvtLike<any>, T> =
import("./types/helper/SwapEvtType").SwapEvtType<E, T>;

type UnpackEvt<T extends ({ [key: string]: any; } | import("./types/helper/UnpackEvt").EvtLike<any>)> =
import("./types/helper/UnpackEvt").UnpackEvt<T>;

type EvtLike<T> = import("./types/helper/UnpackEvt").EvtLike<T>;

Expand Down
4 changes: 3 additions & 1 deletion src/lib/Evt.merge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { UnpackEvt } from "./types/helper/UnpackEvt";
type UnpackEvt<T extends ({ [key: string]: any; } | import("./types/helper/UnpackEvt").EvtLike<any>)> =
import("./types/helper/UnpackEvt").UnpackEvt<T>;

import { importProxy } from "./importProxy";

type Evt<T> = import("./types/interfaces").Evt<T>;
Expand Down
13 changes: 10 additions & 3 deletions src/lib/Evt.parsePropsFromArgs.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@

import { Handler } from "./types/Handler"
import { Operator } from "./types/Operator"
type CtxLike<Result> = import("./types/interfaces").CtxLike<Result>;

namespace Handler {

export type PropsFromArgs<T, U, CtxProp extends CtxLike<any> | undefined = CtxLike<any> | undefined>=
import("./types/Handler").Handler.PropsFromArgs<T,U,CtxProp>;

}

import type { Operator } from "./types/Operator"
import { id } from "../tools/typeSafety/id";
import { compose } from "./util/compose";
import { typeGuard } from "../tools/typeSafety/typeGuard"
type CtxLike<Result> = import("./types/interfaces").CtxLike<Result>;

export function matchAll() { return true; }

Expand Down
2 changes: 1 addition & 1 deletion src/lib/Evt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { loosenType } from "./Evt.loosenType";
import { CtxLike } from "./types/interfaces/CtxLike";
import { safeClearTimeout, safeSetTimeout, Timer } from "../tools/safeSetTimeout";

import { Handler } from "./types/Handler";
import type { Handler } from "./types/Handler";
import { Operator } from "./types/Operator";
type NonPostableEvt<T> = import("./types/interfaces").NonPostableEvt<T>;
type StatefulEvt<T> = import("./types/interfaces").StatefulEvt<T>;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/StatefulEvt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { importProxy } from "./importProxy";
import { invokeOperator } from "./util/invokeOperator";
import { Operator } from "./types/Operator";
import { parsePropsFromArgs } from "./Evt.parsePropsFromArgs";
import { CtxLike } from "./types/interfaces/CtxLike";
import type { CtxLike } from "./types/interfaces/CtxLike";
type Diff<T> = import("./types/interfaces").Diff<T>;
type NonPostableEvt<T> = import("./types/interfaces").NonPostableEvt<T>;
type StatefulReadonlyEvt<T>= import("./types/interfaces").StatefulReadonlyEvt<T>;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/types/Handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Operator } from "./Operator";
type Operator<T, U, CtxResult = any> = import("./Operator").Operator<T, U, CtxResult>;
type EvtLike<T>= import("../types/helper/UnpackEvt").EvtLike<T>;
type CtxLike<Result> = import("../types/interfaces").CtxLike<Result>;

Expand Down
10 changes: 8 additions & 2 deletions src/lib/types/helper/FactorizeEvt.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@

import { SwapEvtType } from "./SwapEvtType";
import { UnpackEvt } from "./UnpackEvt";

type SwapEvtType<E extends import("./UnpackEvt").EvtLike<any>, T> =
import("./SwapEvtType").SwapEvtType<E, T>;

type EvtLike<T>= import("./UnpackEvt").EvtLike<T>;

type UnpackEvt<T extends ({ [key: string]: any; } | EvtLike<any>)> =
import("./UnpackEvt").UnpackEvt<T>;


/** https://docs.evt.land/api/helpertypes#swapevttype-less-than-e-t-greater-than */
export type FactorizeEvt<E extends EvtLike<any>> = SwapEvtType<E, UnpackEvt<E>>;

2 changes: 1 addition & 1 deletion src/lib/types/helper/UnpackCtx.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


interface CtxLike<Result = any> {
export interface CtxLike<Result = any> {
done(result: Result): void;
}

Expand Down
33 changes: 27 additions & 6 deletions src/lib/types/helper/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
export { FactorizeEvt } from "./FactorizeEvt";
export { SwapEvtType } from "./SwapEvtType";
export { ToPostableEvt } from "./ToPostableEvt";
export { ToNonPostableEvt } from "./ToNonPostableEvt";
export { UnpackCtx } from "./UnpackCtx";
export { UnpackEvt, EvtLike } from "./UnpackEvt";
/** Minimal interface that an object have to implement
* to be considered as being most certainly an Evt instance */
export type EvtLike<T>= import("./UnpackEvt").EvtLike<T>;

/** https://docs.evt.land/api/helpertypes#unpackevt-less-than-e-greater-than */
export type UnpackEvt<T extends ({ [key: string]: any; } | EvtLike<any>)> =
import("./UnpackEvt").UnpackEvt<T>;

/** https://docs.evt.land/api/helpertypes#swapevttype-less-than-e-t-greater-than */
export type FactorizeEvt<E extends EvtLike<any>> =
import("./FactorizeEvt").FactorizeEvt<E>;

/** https://docs.evt.land/api/helpertypes#swapevttype-less-than-e-t-greater-than */
export type SwapEvtType<E extends EvtLike<any>, T> =
import("./SwapEvtType").SwapEvtType<E, T>;

/** https://docs.evt.land/api/helpertypes#topostableevt-less-than-e-greater-than */
export type ToPostableEvt<E extends ({ [key: string]: any; } | EvtLike<any>)> =
import("./ToPostableEvt").ToPostableEvt<E>;

/** https://docs.evt.land/api/helpertypes#tononpostableevt-less-than-e-greater-than */
export type ToNonPostableEvt<E extends ({ [key: string]: any; } | EvtLike<any>)> =
import("./ToNonPostableEvt").ToNonPostableEvt<E>;

/** Analog to UnpackEvt<E> Unpack the type argument of a Ctx */
export type UnpackCtx<Ctx extends import("./UnpackCtx").CtxLike<any>> =
import("./UnpackCtx").UnpackCtx<Ctx>;
40 changes: 39 additions & 1 deletion src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,44 @@ export * from "./helper";
export * from "./interfaces";
export { EventTargetLike } from "./EventTargetLike";
export { EvtError } from "./EvtError";
export { Handler } from "./Handler";

type CtxLike<Result> = import("../types/interfaces").CtxLike<Result>;

/** https://docs.evt.land/api/handler */
export type Handler<T, U, CtxProp extends CtxLike<any> | undefined = CtxLike<any> | undefined> =
import("./Handler").Handler<T, U, CtxProp>;

export namespace Handler {

/** Handlers params that come from the arguments passed to the method invoked */
export type PropsFromArgs<T, U, CtxProp extends CtxLike<any> | undefined = CtxLike<any> | undefined> =
import("./Handler").Handler.PropsFromArgs<T, U, CtxProp>;

/**
* Handlers params that are implicitly specified by the method used:
* attachOnce => once
* attachOncePrepend => once + prepend
* waitFor => once + async
* ...
*/
export type PropsFromMethodName =
import("./Handler").Handler.PropsFromMethodName;

export namespace PropsFromMethodName {

export type Sync =
import("./Handler").Handler.PropsFromMethodName.Sync;

export type Async =
import("./Handler").Handler.PropsFromMethodName.Async;

}

export type WithEvt<T, CtxResult> =
import("./Handler").Handler.WithEvt<T, CtxResult>;


}

import * as dom from "./lib.dom"; export { dom };
export { Operator } from "./Operator";
13 changes: 11 additions & 2 deletions src/lib/types/interfaces/Ctx.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@

import { Handler } from "../Handler";
type CtxLike<T> = import("./CtxLike").CtxLike<T>;

type Handler<T, U, CtxProp extends CtxLike<any> | undefined = CtxLike<any> | undefined> =
import("../Handler").Handler<T, U, CtxProp>;

namespace Handler {

export type WithEvt<T, CtxResult> =
import("../Handler").Handler.WithEvt<T, CtxResult>;

}

type EvtLike<T> = import("../helper/UnpackEvt").EvtLike<T>;
type Evt<T> = import("./Evt").Evt<T>;
type CtxLike<T> = import("./CtxLike").CtxLike<T>;

export type DoneOrAborted<Result> = DoneOrAborted.Done<Result> | DoneOrAborted.Aborted<Result>;

Expand Down
4 changes: 3 additions & 1 deletion src/lib/types/interfaces/CtxLike.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

import { Handler } from "../Handler";
import { typeGuard } from "../../../tools/typeSafety/typeGuard";
type EvtLike<T> = import("../helper/UnpackEvt").EvtLike<T>;

type Handler<T, U, CtxProp extends CtxLike<any> | undefined = CtxLike<any> | undefined> =
import("../Handler").Handler<T, U, CtxProp>;

/**
* Minimal interface that an object must implement to be a valid context argument
* ( for interop between mismatching EVT versions )
Expand Down
26 changes: 24 additions & 2 deletions src/lib/types/interfaces/NonPostableEvt.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
import { Handler } from "../Handler";
import { Operator } from "../Operator";


export type Operator<T, U, CtxResult = any> =
import("../Operator").Operator<T, U, CtxResult>;

namespace Operator {

export type fλ<T, U, CtxResult = any> =
import("../Operator").Operator.fλ<T, U, CtxResult>;

export namespace fλ {

export type Stateless<T, U, CtxResult = any> =
import("../Operator").Operator.fλ.Stateless<T, U, CtxResult>;

}

export type Stateless<T, U, CtxResult = any> =
import("../Operator").Operator.Stateless<T, U, CtxResult>;

}

type StatefulEvt<T> = import("./StatefulEvt").StatefulEvt<T>;
type CtxLike<Result = any> = import("./CtxLike").CtxLike<Result>;
type Evt<T> = import("./Evt").Evt<T>;

type Handler<T, U, CtxProp extends CtxLike<any> | undefined = CtxLike<any> | undefined> =
import("../Handler").Handler<T, U, CtxProp>;


export interface NonPostableEvt<T> {

Expand Down
10 changes: 9 additions & 1 deletion src/lib/types/interfaces/StatefulReadonlyEvt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@

import { Operator } from "../Operator";
export type Operator<T, U, CtxResult = any> =
import("../Operator").Operator<T, U, CtxResult>;

namespace Operator {

export type fλ<T, U, CtxResult = any> =
import("../Operator").Operator.fλ<T, U, CtxResult>;

}

type NonPostableEvt<T> = import("./NonPostableEvt").NonPostableEvt<T>;
type CtxLike<Result = any> = import("./CtxLike").CtxLike<Result>;
Expand Down
8 changes: 7 additions & 1 deletion src/lib/types/interfaces/VoidCtx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@

import { Handler } from "../Handler";

namespace Handler {

export type WithEvt<T,CtxResult> =
import("../Handler").Handler.WithEvt<T, CtxResult>;

}

type Ctx<T> = import("./Ctx").Ctx<T>;

Expand Down
42 changes: 32 additions & 10 deletions src/lib/types/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
export { Ctx, DoneOrAborted } from "./Ctx";
export { CtxLike, VoidCtxLike } from "./CtxLike";
export { Evt } from "./Evt";
export { NonPostableEvt } from "./NonPostableEvt";
export { Postable } from "./Postable";
export { StatefulEvt } from "./StatefulEvt";
export { StatefulReadonlyEvt, StateDiff as Diff } from "./StatefulReadonlyEvt";
export { StatefulPostable } from "./StatefulPostable";
export { VoidCtx } from "./VoidCtx";
export { VoidEvt } from "./VoidEvt";

/** https://docs.evt.land/api/ctx */
export type Ctx<Result> = import("./Ctx").Ctx<Result>;
export type DoneOrAborted<Result> = import("./Ctx").DoneOrAborted<Result>;
export { CtxLike } from "./CtxLike";
/**
* Minimal interface that an object must implement to be a valid context argument
* ( for interop between mismatching EVT versions )
*/
export type VoidCtxLike = import("./CtxLike").CtxLike;
export type Evt<T> = import("./Evt").Evt<T>;
export type NonPostableEvt<T>= import("./NonPostableEvt").NonPostableEvt<T>;
export type Postable<T> = import("./Postable").Postable<T>;
export type StatefulEvt<T> = import("./StatefulEvt").StatefulEvt<T>;

export type StatefulReadonlyEvt<T>= import("./StatefulReadonlyEvt").StatefulReadonlyEvt<T>;
export type Diff<T> = import("./StatefulReadonlyEvt").StateDiff<T>;
export type StatefulPostable<T> = import("./StatefulPostable").StatefulPostable<T>;
/**
* https://docs.evt.land/api/evt/ctx
*
* Only an interface (not a class), use Evt.newCtx() to get an instance.
*/
export type VoidCtx = import("./VoidCtx").VoidCtx;
/**
* https://docs.evt.land/api/evt/create#why-voidevt-and-not-evt-less-than-void-greater-than
* https://docs.evt.land/api/evt/create
*
* This is only an interface, not a class.
* get an instance using Evt.create()
* */
export type VoidEvt = import("./VoidEvt").VoidEvt;
1 change: 1 addition & 0 deletions src/lib/types/lib.dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */

export const __hack= "NOT TYPE ONLY";

/////////////////////////////
/// DOM APIs
Expand Down
Loading