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

Add TypeScript types for observer parameters. #5359

Merged
merged 5 commits into from
Sep 16, 2018
Merged
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
41 changes: 41 additions & 0 deletions interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,47 @@ export type BehaviorInit = Pick<
Exclude<keyof PolymerInit, "is" | "extends" | "_template">
>;

/**
* The object passed to ".*" wildcard obsevers. A record of a change made to an
* object.
* @template B The object matching the non-wildcard portion of the path.
* @template V Additional types that could be set at the path.
*/
export interface PolymerDeepPropertyChange<B, V> {
/** Path to the property that changed. */
path: string;
/** The object matching the non-wildcard portion of the path. */
base: B;
/** New value of the path that changed. */
value: B|V;
rictic marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* A record of changes made to an array.
* @template T The type of the array being observed.
*/
export interface PolymerSplice<T extends Array<{}|null|undefined>> {
/** Position where the splice started. */
index: number;
/** Array of removed items. */
removed: T;
/** Number of new items inserted at index. */
addedCount: number;
/** A reference to the array in question. */
object: T;
/** The string literal 'splice'. */
type: 'splice';
}

/**
* The object passed to ".splices" observers. A set of mutations made to the
* array.
* @template T The type of the array being observed.
*/
export interface PolymerSpliceChange<T extends Array<{}|null|undefined>> {
indexSplices: Array<PolymerSplice<T>>;
}

// Types from "externs/polymer-internal-shared-types.js"

export interface StampedTemplate extends DocumentFragment {
Expand Down