Skip to content

Commit

Permalink
🏷️ Fix context types
Browse files Browse the repository at this point in the history
  • Loading branch information
wwilsman committed Mar 12, 2024
1 parent ded1875 commit 87cfcb1
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions lib/context.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSelectorFunction } from './selector.js';

/**
* @template {{ [key: string]: any }} [T = {}]
* @template {{}} [T = {}]
* @template [TReturn = any]
* @typedef {(
* (context: IContext<T>) => ContextYield<TReturn> | TReturn
Expand All @@ -10,7 +10,7 @@ import { createSelectorFunction } from './selector.js';

/**
* @template [T = any]
* @template {{ [key: string]: any }} [C = {}]
* @template {{}} [C = {}]
* @typedef {(
* ContextGenerator<C, T> | ContextFunction<C, T> | T |
* string | number | boolean | undefined | null | void |
Expand All @@ -19,7 +19,7 @@ import { createSelectorFunction } from './selector.js';
*/

/**
* @template {{ [key: string]: any }} [T = {}]
* @template {{}} [T = {}]
* @template {any} [TReturn = any]
* @typedef {(Generator<
* ContextYield<TReturn, T>,
Expand All @@ -28,8 +28,9 @@ import { createSelectorFunction } from './selector.js';
*/

/**
* @template {{ [key: string]: any }} [T = {}]
* @template {{}} [T = {}]
* @typedef {T & {
* [key: string]: any
* root?: () => HTMLElement
* selector?: import('./selector').Selector
* immediate?: ContextOptions<T>
Expand All @@ -43,12 +44,12 @@ import { createSelectorFunction } from './selector.js';
*/

/**
* @template {{ [key: string]: any }} [T = {}]
* @template {{}} [T = {}]
* @typedef {Context<T> & T} IContext
*/

/**
* @template {{ [key: string]: any }} [T = {}]
* @template {{}} [T = {}]
*/
export class Context {
static Symbol = Symbol('@@interactor|context');
Expand Down Expand Up @@ -89,19 +90,13 @@ export class Context {
), { toString: () => 'root element' })
});

/** @type {Object} */
this.assert = {
/** @type {number} */
timeout: 1000,
/** @type {number} */
frequency: 60,
/** @type {number} */
reliability: 1
};

/** @type {this} */
this.immediate = this;

this.set(rest);
}

Expand Down Expand Up @@ -135,9 +130,7 @@ export class Context {
return this.selector({ all: true });
}

/**
* @type {(options: ContextOptions<T>) => this}
*/
/** @type {(options: ContextOptions<T>) => this} */
get set() {
// @ts-ignore
return ({ immediate, assert, ...rest }) => {
Expand Down

0 comments on commit 87cfcb1

Please sign in to comment.