diff --git a/src/beagle-tree/iteration.ts b/src/beagle-tree/iteration.ts index daddbc0f..98b85bf1 100644 --- a/src/beagle-tree/iteration.ts +++ b/src/beagle-tree/iteration.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { Iterator } from 'types' import { BeagleUIElement } from './types' type Iteratee = (item: ItemType, index: number) => ReturnType diff --git a/src/legacy/beagle-context.ts b/src/legacy/beagle-context.ts index 884509e5..17d2eb59 100644 --- a/src/legacy/beagle-context.ts +++ b/src/legacy/beagle-context.ts @@ -19,6 +19,7 @@ import { IdentifiableBeagleUIElement } from 'beagle-tree/types' import { LoadParams, BeagleView, UpdateWithTreeParams } from 'beagle-view/types' import { ViewContentManager } from 'service/view-content-manager/types' +import { Omit } from 'types' /** * @deprecated since v1.2. Will de deleted in v2.0. Use `ViewContentManager` instead. diff --git a/src/types.ts b/src/types.ts index 3a055233..d8de43ec 100644 --- a/src/types.ts +++ b/src/types.ts @@ -14,8 +14,32 @@ * limitations under the License. */ +/* compatibility mode: older versions of Typescript that must be supported by Beagle (>= 3.1.1) +don't have "Omit" natively */ export type Omit = Pick> +/* The following 4 types have been copied from the original ES6 module definition and slightly +altered. This must be done because we must target ES5 in our build, which doesn't have support to +iterators. It's true that iterators won't work in ES5 environments, but we don't want to limit +Beagle for people using ES6 or later. */ +export interface IteratorYieldResult { + done?: false, + value: TYield, +} + +export interface IteratorReturnResult { + done: true, + value: any, +} + +export type IteratorResult = IteratorYieldResult | IteratorReturnResult + +export interface Iterator { + next(...args: []): IteratorResult, + return?(value?: any): IteratorResult, + throw?(e?: any): IteratorResult, +} + // todo: legacy code, remove with v2.0 import { ClickEvent as CE, ScreenEvent as SE } from 'service/beagle-service/types' import { IdentifiableBeagleUIElement as IBE, BeagleUIElement as BE } from 'beagle-tree/types' diff --git a/tsconfig.json b/tsconfig.json index 22dee7cd..4b79de2f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,7 +22,8 @@ "metadata/*": ["metadata/*"], "operation/*": ["operation/*"], "service/*": ["service/*"], - "utils/*": ["utils/*"] + "utils/*": ["utils/*"], + "types/*": ["types/*"] } }, "include": [