Skip to content

Commit

Permalink
update ContextHelper types with generics
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalexiei authored and evs-chris committed Apr 17, 2021
1 parent 03d22dc commit 0ee55ac
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions typings/ractive.d.ts
Expand Up @@ -102,7 +102,7 @@ export class ContextHelper {
* @param keypath a Context-relative keypath to a number
* @param amount the amount to add to the target number - defaults to 1
*/
add(keypath: string, amount?: number): Promise<void>;
add(keypath: string, amount?: number): Promise<number>;

/**
* Animate the value at the given keypath from its current value to the given value.
Expand All @@ -117,53 +117,53 @@ export class ContextHelper {
* @param selector query used to find the first matching element
* @param opts
*/
find(selector: string, opts?: FindOpts): HTMLElement;
find<U extends Element = HTMLElement>(selector: string, opts?: FindOpts): U;

/**
* Find all of the elements in the DOM controlled by this instance that match the given selector.
* @param selector query used to match elements
* @param opts
*/
findAll(selector: string, opts?: FindOpts): HTMLElement[];
findAll<U extends Element = HTMLElement>(selector: string, opts?: FindOpts): U[];

/**
* Find all of the components belonging to this instance.
* @param opts
*/
findAllComponents(opts?: FindOpts): Ractive[];
findAllComponents<U extends Ractive = Ractive>(opts?: FindOpts): U[];

/**
* Find all of the components with the given name belonging to this instance.
* @param name
* @param opts
*/
findAllComponents(name: string, opts?: FindOpts): Ractive[];
findAllComponents<U extends Ractive = Ractive>(name: string, opts?: FindOpts): U[];

/**
* Find the first component belonging to this instance.
* @param opts
*/
findComponent(opts?: FindOpts): Ractive;
findComponent<U extends Ractive = Ractive>(opts?: FindOpts): U;

/**
* Find the first component with the given name belonging to this instance.
* @param name
* @param opts
*/
findComponent(name: string, opts?: FindOpts): Ractive;
findComponent<U extends Ractive = Ractive>(name: string, opts?: FindOpts): U;

/**
* Retrieve the value associated with the current Context.
* @param opts
*/
get(opts?: GetOpts): any
get<U = any>(opts?: GetOpts): U

/**
* Retrieve the value at the given keypath.
* @param keypath a Context-relative keypath to the value
* @param opts
*/
get(keypath: string, opts?: GetOpts): any;
get<U = any>(keypath: string, opts?: GetOpts): U;

/**
* Retrieve the value associated with the twoway binding of the element e.g. .value in <input value="{{.value}}" />.
Expand Down Expand Up @@ -357,7 +357,7 @@ export class ContextHelper {
* @param keypath
* @param amount the amount to subtract from the value - defaults to 1
*/
subtract(keypath: string, amount?: number): Promise<void>;
subtract(keypath: string, amount?: number): Promise<number>;

/**
* Toggle the value at the given Context-relative keypath. If it is truthy, set it to false, otherwise, set it to true.
Expand Down

0 comments on commit 0ee55ac

Please sign in to comment.