Skip to content

Commit

Permalink
New typings.
Browse files Browse the repository at this point in the history
  • Loading branch information
aomarks committed Dec 16, 2017
1 parent 266d599 commit a1f3317
Show file tree
Hide file tree
Showing 20 changed files with 459 additions and 298 deletions.
10 changes: 5 additions & 5 deletions types/lib/elements/array-selector.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,33 @@ declare namespace Polymer {
/**
* An array containing items from which selection will be made.
*/
items: any[]|null;
items: any[]|null|undefined;

/**
* When `true`, multiple items may be selected at once (in this case,
* `selected` is an array of currently selected items). When `false`,
* only one item may be selected at a time.
*/
multi: boolean;
multi: boolean|null|undefined;

/**
* When `multi` is true, this is an array that contains any selected.
* When `multi` is false, this is the currently selected item, or `null`
* if no item is selected.
*/
selected: Object|Object[]|null;
selected: object|object[]|null;

/**
* When `multi` is false, this is the currently selected item, or `null`
* if no item is selected.
*/
selectedItem: Object|null;
selectedItem: object|null;

/**
* When `true`, calling `select` on an item that is already selected
* will deselect the item.
*/
toggle: boolean;
toggle: boolean|null|undefined;

/**
* Clears the selection state.
Expand Down
4 changes: 2 additions & 2 deletions types/lib/elements/dom-if.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ declare namespace Polymer {
/**
* A boolean indicating whether this template should stamp.
*/
if: boolean;
if: boolean|null|undefined;

/**
* When true, elements will be removed from DOM and discarded when `if`
Expand All @@ -44,7 +44,7 @@ declare namespace Polymer {
* in the DOM when `if` becomes false, which is generally results
* in better performance.
*/
restamp: boolean;
restamp: boolean|null|undefined;
connectedCallback(): any;
disconnectedCallback(): any;

Expand Down
8 changes: 7 additions & 1 deletion types/lib/elements/dom-module.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ declare namespace Polymer {
* let img = customElements.get('dom-module').import('foo', 'img');
*/
class DomModule extends HTMLElement {
attributeChangedCallback(name: string, old: any, value: any): void;

/**
* @param name Name of attribute.
* @param old Old value of attribute.
* @param value Current value of attribute.
*/
attributeChangedCallback(name: string, old: string|null, value: string|null): void;

/**
* Registers the dom-module at a given id. This method should only be called
Expand Down
24 changes: 12 additions & 12 deletions types/lib/elements/dom-repeat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,29 +111,29 @@ declare namespace Polymer {
* An array containing items determining how many instances of the template
* to stamp and that that each template instance should bind to.
*/
items: any[]|null;
items: any[]|null|undefined;

/**
* The name of the variable to add to the binding scope for the array
* element associated with a given template instance.
*/
as: string;
as: string|null|undefined;

/**
* The name of the variable to add to the binding scope with the index
* of the instance in the sorted and filtered list of rendered items.
* Note, for the index in the `this.items` array, use the value of the
* `itemsIndexAs` property.
*/
indexAs: string;
indexAs: string|null|undefined;

/**
* The name of the variable to add to the binding scope with the index
* of the instance in the `this.items` array. Note, for the index of
* this instance in the sorted and filtered list of rendered items,
* use the value of the `indexAs` property.
*/
itemsIndexAs: string;
itemsIndexAs: string|null|undefined;

/**
* A function that should determine the sort order of the items. This
Expand All @@ -142,7 +142,7 @@ declare namespace Polymer {
* function should match the sort function passed to `Array.sort`.
* Using a sort function has no effect on the underlying `items` array.
*/
sort: Function|null;
sort: Function|null|undefined;

/**
* A function that can be used to filter items out of the view. This
Expand All @@ -151,7 +151,7 @@ declare namespace Polymer {
* function should match the sort function passed to `Array.filter`.
* Using a filter function has no effect on the underlying `items` array.
*/
filter: Function|null;
filter: Function|null|undefined;

/**
* When using a `filter` or `sort` function, the `observe` property
Expand All @@ -160,7 +160,7 @@ declare namespace Polymer {
* These should generally be fields of `item` that the sort or filter
* function depends on.
*/
observe: string;
observe: string|null|undefined;

/**
* When using a `filter` or `sort` function, the `delay` property
Expand All @@ -169,14 +169,14 @@ declare namespace Polymer {
* This is useful in rate-limiting shuffling of the view when
* item changes may be frequent.
*/
delay: number;
delay: number|null|undefined;

/**
* Count of currently rendered items after `filter` (if any) has been applied.
* If "chunking mode" is enabled, `renderedItemCount` is updated each time a
* set of template instances is rendered.
*/
renderedItemCount: number;
renderedItemCount: number|null|undefined;

/**
* Defines an initial count of template instances to render after setting
Expand All @@ -185,7 +185,7 @@ declare namespace Polymer {
* incrementally at each animation frame therof until all instances have
* been rendered.
*/
initialCount: number;
initialCount: number|null|undefined;

/**
* When `initialCount` is used, this property defines a frame rate (in
Expand All @@ -199,8 +199,8 @@ declare namespace Polymer {
* throughput for event handlers and other tasks, but results in a
* longer time for the remaining items to complete rendering.
*/
targetFramerate: number;
_targetFrameTime: number;
targetFramerate: number|null|undefined;
_targetFrameTime: number|null|undefined;
disconnectedCallback(): any;
connectedCallback(): any;

Expand Down
2 changes: 1 addition & 1 deletion types/lib/legacy/class.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ declare namespace Polymer {
* @returns Returns a new Element class extended by the
* passed in `behaviors` and also by `Polymer.LegacyElementMixin`.
*/
function mixinBehaviors(behaviors: Object|any[]|null, klass: HTMLElement|{new(): HTMLElement}): {new(): HTMLElement};
function mixinBehaviors(behaviors: object|any[]|null, klass: HTMLElement|{new(): HTMLElement}): {new(): HTMLElement};


/**
Expand Down
30 changes: 15 additions & 15 deletions types/lib/legacy/legacy-element-mixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ declare namespace Polymer {
_debouncers: any;

/**
* Provides an override implementation of `attributeChangedCallback`
* which adds the Polymer legacy API's `attributeChanged` method.
*
* @param name Name of attribute.
* @param old Old value of attribute.
* @param value Current value of attribute.
* Overrides the default `Polymer.PropertyEffects` implementation to
* add support for installing `hostAttributes` and `listeners`.
*/
attributeChangedCallback(name: string, old: string|null, value: string|null): void;
ready(): any;

/**
* Overrides the default `Polymer.PropertyEffects` implementation to
Expand All @@ -51,10 +47,14 @@ declare namespace Polymer {
_initializeProperties(): any;

/**
* Overrides the default `Polymer.PropertyEffects` implementation to
* add support for installing `hostAttributes` and `listeners`.
* Provides an override implementation of `attributeChangedCallback`
* which adds the Polymer legacy API's `attributeChanged` method.
*
* @param name Name of attribute.
* @param old Old value of attribute.
* @param value Current value of attribute.
*/
ready(): any;
attributeChangedCallback(name: string, old: string|null, value: string|null): void;

/**
* Provides an implementation of `connectedCallback`
Expand Down Expand Up @@ -187,7 +187,7 @@ declare namespace Polymer {
* @param api Source object to copy properties from.
* @returns prototype object that was passed as first argument.
*/
extend(prototype: Object|null, api: Object|null): Object|null;
extend(prototype: object|null, api: object|null): object|null;

/**
* Copies props from a source object to a target object.
Expand All @@ -200,7 +200,7 @@ declare namespace Polymer {
* @param source Source object to copy properties from.
* @returns Target object that was passed as first argument.
*/
mixin(target: Object|null, source: Object|null): Object|null;
mixin(target: object|null, source: object|null): object|null;

/**
* Sets the prototype of an object.
Expand All @@ -214,7 +214,7 @@ declare namespace Polymer {
* @returns Returns the given `object` with its prototype set
* to the given `prototype` object.
*/
chainObject(object: Object|null, prototype: Object|null): Object|null;
chainObject(object: object|null, prototype: object|null): object|null;

/**
* Calls `importNode` on the `content` of the `template` specified and
Expand Down Expand Up @@ -435,7 +435,7 @@ declare namespace Polymer {
* `flush()` immediately invokes the debounced callback if the debouncer
* is active.
*/
debounce(jobName: string, callback: () => void, wait: number): Object|null;
debounce(jobName: string, callback: () => void, wait: number): object|null;

/**
* Returns whether a named debouncer is active.
Expand Down Expand Up @@ -489,7 +489,7 @@ declare namespace Polymer {
* instance.
* @returns Newly created and configured element.
*/
create(tag: string, props: Object|null): Element|null;
create(tag: string, props: object|null): Element|null;

/**
* Convenience method for importing an HTML document imperatively.
Expand Down
2 changes: 1 addition & 1 deletion types/lib/legacy/mutable-data-behavior.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ declare namespace Polymer {
* for this element. When true, Objects and Arrays will skip dirty
* checking, otherwise strict equality checking will be used.
*/
mutableData: boolean;
mutableData: boolean|null|undefined;

/**
* Overrides `Polymer.PropertyEffects` to skip strict equality checking
Expand Down
2 changes: 1 addition & 1 deletion types/lib/legacy/polymer.dom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ declare namespace Polymer {
*
* @returns True if node matched selector
*/
function matchesSelector(node: Element, selector: string): boolean;
function matchesSelector(node: Node, selector: string): boolean;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion types/lib/legacy/templatizer-behavior.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ declare namespace Polymer {
* @returns Returns the created instance of
* the template prepared by `templatize`.
*/
stamp(model?: Object|null): TemplateInstanceBase|null;
stamp(model?: object|null): TemplateInstanceBase|null;

/**
* Returns the template "model" (`TemplateInstance`) associated with
Expand Down
31 changes: 5 additions & 26 deletions types/lib/mixins/element-mixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
/// <reference path="../utils/boot.d.ts" />
/// <reference path="../utils/settings.d.ts" />
/// <reference path="../utils/mixin.d.ts" />
/// <reference path="../utils/case-map.d.ts" />
/// <reference path="../utils/style-gather.d.ts" />
/// <reference path="../utils/resolve-url.d.ts" />
/// <reference path="../elements/dom-module.d.ts" />
/// <reference path="property-effects.d.ts" />
/// <reference path="properties-mixin.d.ts" />

declare namespace Polymer {

Expand Down Expand Up @@ -76,7 +76,7 @@ declare namespace Polymer {
* of dash-cased attributes based on `properties`)
*/
function ElementMixin<T extends new(...args: any[]) => {}>(base: T): {
new(...args: any[]): ElementMixin & Polymer.PropertyEffects
new(...args: any[]): ElementMixin & Polymer.PropertyEffects & Polymer.PropertiesMixin
} & T

interface ElementMixin {
Expand All @@ -88,19 +88,9 @@ declare namespace Polymer {
$: any;

/**
* Provides a default implementation of the standard Custom Elements
* `attributeChangedCallback`.
*
* By default, attributes declared in `properties` metadata are
* deserialized using their `type` information to properties of the
* same name. "Dash-cased" attributes are deserialized to "camelCase"
* properties.
*
* @param name Name of attribute.
* @param old Old value of attribute.
* @param value Current value of attribute.
* Stamps the element template.
*/
attributeChangedCallback(name: string, old: string|null, value: string|null): any;
ready(): any;

/**
* Overrides the default `Polymer.PropertyAccessors` to ensure class
Expand All @@ -112,11 +102,6 @@ declare namespace Polymer {
*/
_initializeProperties(): any;

/**
* Stamps the element template.
*/
ready(): any;

/**
* Implements `PropertyEffects`'s `_readyClients` call. Attaches
* element dom by calling `_attachDom` with the dom stamped from the
Expand All @@ -136,12 +121,6 @@ declare namespace Polymer {
*/
connectedCallback(): any;

/**
* Provides a default implementation of the standard Custom Elements
* `disconnectedCallback`.
*/
disconnectedCallback(): any;

/**
* Attaches an element's stamped dom to itself. By default,
* this method creates a `shadowRoot` and adds the dom to it.
Expand Down Expand Up @@ -169,7 +148,7 @@ declare namespace Polymer {
* @param properties Bag of custom property key/values to
* apply to this element.
*/
updateStyles(properties?: Object|null): void;
updateStyles(properties?: object|null): void;

/**
* Rewrites a given URL relative to a base URL. The base URL defaults to
Expand Down
2 changes: 1 addition & 1 deletion types/lib/mixins/mutable-data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ declare namespace Polymer {
* for this element. When true, Objects and Arrays will skip dirty
* checking, otherwise strict equality checking will be used.
*/
mutableData: boolean;
mutableData: boolean|null|undefined;

/**
* Overrides `Polymer.PropertyEffects` to provide option for skipping
Expand Down
Loading

0 comments on commit a1f3317

Please sign in to comment.