From 5bc45ce39071fd881254f7f6445939a1a624b3cb Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Wed, 21 Feb 2018 10:28:07 -0800 Subject: [PATCH] update types --- externs/closure-types.js | 28 +++++++- test/unit/disable-upgrade.html | 2 +- types/externs/closure-types.d.ts | 10 +++ types/externs/polymer-externs.d.ts | 10 +++ .../polymer-internal-shared-types.d.ts | 10 +++ types/externs/webcomponents-externs.d.ts | 10 +++ types/gulpfile.d.ts | 18 +++++ types/lib/elements/array-selector.d.ts | 2 +- types/lib/elements/dom-module.d.ts | 13 ---- types/lib/legacy/legacy-element-mixin.d.ts | 2 +- types/lib/legacy/mutable-data-behavior.d.ts | 4 -- types/lib/legacy/templatizer-behavior.d.ts | 2 - types/lib/mixins/dir-mixin.d.ts | 2 +- types/lib/mixins/disable-upgrade-mixin.d.ts | 65 +++++++++++++++++++ types/lib/mixins/element-mixin.d.ts | 2 +- types/lib/mixins/properties-changed.d.ts | 4 +- types/lib/mixins/properties-mixin.d.ts | 2 +- types/lib/mixins/property-accessors.d.ts | 8 +-- types/lib/mixins/property-effects.d.ts | 2 +- types/util/minimalDocument.d.ts | 13 ++++ 20 files changed, 176 insertions(+), 33 deletions(-) create mode 100644 types/externs/closure-types.d.ts create mode 100644 types/externs/polymer-externs.d.ts create mode 100644 types/externs/polymer-internal-shared-types.d.ts create mode 100644 types/externs/webcomponents-externs.d.ts create mode 100644 types/gulpfile.d.ts create mode 100644 types/lib/mixins/disable-upgrade-mixin.d.ts create mode 100644 types/util/minimalDocument.d.ts diff --git a/externs/closure-types.js b/externs/closure-types.js index 0cabb51658..d1f9ec23e5 100644 --- a/externs/closure-types.js +++ b/externs/closure-types.js @@ -1374,4 +1374,30 @@ Polymer_ArraySelectorMixin.prototype.select = function(item){}; * @param {number} idx Index from `items` array to select * @return {void} */ -Polymer_ArraySelectorMixin.prototype.selectIndex = function(idx){}; \ No newline at end of file +Polymer_ArraySelectorMixin.prototype.selectIndex = function(idx){}; +/** +* @interface +*/ +function Polymer_DisableUpgradeMixin(){} +/** +* @param {*} name +* @param {*} old +* @param {*} value +*/ +Polymer_DisableUpgradeMixin.prototype.attributeChangedCallback = function(name, old, value){}; +/** +* @return {undefined} +*/ +Polymer_DisableUpgradeMixin.prototype._initializeProperties = function(){}; +/** +* @return {undefined} +*/ +Polymer_DisableUpgradeMixin.prototype.connectedCallback = function(){}; +/** +* @return {undefined} +*/ +Polymer_DisableUpgradeMixin.prototype._enableProperties = function(){}; +/** +* @return {undefined} +*/ +Polymer_DisableUpgradeMixin.prototype.disconnectedCallback = function(){}; \ No newline at end of file diff --git a/test/unit/disable-upgrade.html b/test/unit/disable-upgrade.html index 533476e81b..6d7c6af1d3 100644 --- a/test/unit/disable-upgrade.html +++ b/test/unit/disable-upgrade.html @@ -79,7 +79,7 @@

[[prop]]

Polymer.Class = function(info) { const ctor = polymerClass(info); return Polymer.DisableUpgradeMixin(ctor); - } + }; Polymer({ is: 'x-disabled-legacy', diff --git a/types/externs/closure-types.d.ts b/types/externs/closure-types.d.ts new file mode 100644 index 0000000000..a9dac916c2 --- /dev/null +++ b/types/externs/closure-types.d.ts @@ -0,0 +1,10 @@ +/** + * DO NOT EDIT + * + * This file was automatically generated by + * https://github.com/Polymer/gen-typescript-declarations + * + * To modify these typings, edit the source file(s): + * externs/closure-types.js + */ + diff --git a/types/externs/polymer-externs.d.ts b/types/externs/polymer-externs.d.ts new file mode 100644 index 0000000000..6cf2cc7426 --- /dev/null +++ b/types/externs/polymer-externs.d.ts @@ -0,0 +1,10 @@ +/** + * DO NOT EDIT + * + * This file was automatically generated by + * https://github.com/Polymer/gen-typescript-declarations + * + * To modify these typings, edit the source file(s): + * externs/polymer-externs.js + */ + diff --git a/types/externs/polymer-internal-shared-types.d.ts b/types/externs/polymer-internal-shared-types.d.ts new file mode 100644 index 0000000000..f6fef0f1fe --- /dev/null +++ b/types/externs/polymer-internal-shared-types.d.ts @@ -0,0 +1,10 @@ +/** + * DO NOT EDIT + * + * This file was automatically generated by + * https://github.com/Polymer/gen-typescript-declarations + * + * To modify these typings, edit the source file(s): + * externs/polymer-internal-shared-types.js + */ + diff --git a/types/externs/webcomponents-externs.d.ts b/types/externs/webcomponents-externs.d.ts new file mode 100644 index 0000000000..87cdda9b58 --- /dev/null +++ b/types/externs/webcomponents-externs.d.ts @@ -0,0 +1,10 @@ +/** + * DO NOT EDIT + * + * This file was automatically generated by + * https://github.com/Polymer/gen-typescript-declarations + * + * To modify these typings, edit the source file(s): + * externs/webcomponents-externs.js + */ + diff --git a/types/gulpfile.d.ts b/types/gulpfile.d.ts new file mode 100644 index 0000000000..2d52f67506 --- /dev/null +++ b/types/gulpfile.d.ts @@ -0,0 +1,18 @@ +/** + * DO NOT EDIT + * + * This file was automatically generated by + * https://github.com/Polymer/gen-typescript-declarations + * + * To modify these typings, edit the source file(s): + * gulpfile.js + */ + +declare class BackfillStream { + _transform(file: any, enc: any, cb: any): any; + _flush(cb: any): any; +} + +declare class AddClosureTypeImport { + _transform(file: any, enc: any, cb: any): any; +} diff --git a/types/lib/elements/array-selector.d.ts b/types/lib/elements/array-selector.d.ts index 1d99ee52e4..8a009f1248 100644 --- a/types/lib/elements/array-selector.d.ts +++ b/types/lib/elements/array-selector.d.ts @@ -29,7 +29,7 @@ declare namespace Polymer { * representing the last selected item. When `multi` is true, `selected` * is an array of multiply selected items. */ - function ArraySelectorMixin {}>(base: T): T & ArraySelectorMixinConstructor & Polymer.ElementMixinConstructor & Polymer.PropertyEffectsConstructor & Polymer.TemplateStampConstructor & Polymer.PropertyAccessorsConstructor & Polymer.PropertiesChangedConstructor & Polymer.PropertiesMixinConstructor; + function ArraySelectorMixin {}>(base: T): T & ArraySelectorMixinConstructor & Polymer.ElementMixinConstructor; interface ArraySelectorMixinConstructor { new(...args: any[]): ArraySelectorMixin; diff --git a/types/lib/elements/dom-module.d.ts b/types/lib/elements/dom-module.d.ts index 7229968d42..960513849d 100644 --- a/types/lib/elements/dom-module.d.ts +++ b/types/lib/elements/dom-module.d.ts @@ -33,19 +33,6 @@ declare namespace Polymer { * let img = customElements.get('dom-module').import('foo', 'img'); */ class DomModule extends HTMLElement { - - /** - * The absolute URL of the original location of this `dom-module`. - * - * This value will differ from this element's `ownerDocument` in the - * following ways: - * - Takes into account any `assetpath` attribute added during bundling - * to indicate the original location relative to the bundled location - * - Uses the HTMLImports polyfill's `importForElement` API to ensure - * the path is relative to the import document's location since - * `ownerDocument` is not currently polyfilled - * - */ readonly assetpath: any; /** diff --git a/types/lib/legacy/legacy-element-mixin.d.ts b/types/lib/legacy/legacy-element-mixin.d.ts index cfe9164678..d8b1fb0dfa 100644 --- a/types/lib/legacy/legacy-element-mixin.d.ts +++ b/types/lib/legacy/legacy-element-mixin.d.ts @@ -26,7 +26,7 @@ declare namespace Polymer { * found on the Polymer 1.x `Polymer.Base` prototype applied to all elements * defined using the `Polymer({...})` function. */ - function LegacyElementMixin {}>(base: T): T & LegacyElementMixinConstructor & Polymer.ElementMixinConstructor & Polymer.PropertyEffectsConstructor & Polymer.TemplateStampConstructor & Polymer.PropertyAccessorsConstructor & Polymer.PropertiesChangedConstructor & Polymer.PropertiesMixinConstructor & Polymer.GestureEventListenersConstructor; + function LegacyElementMixin {}>(base: T): T & LegacyElementMixinConstructor & Polymer.ElementMixinConstructor & Polymer.GestureEventListenersConstructor; interface LegacyElementMixinConstructor { new(...args: any[]): LegacyElementMixin; diff --git a/types/lib/legacy/mutable-data-behavior.d.ts b/types/lib/legacy/mutable-data-behavior.d.ts index ea580cc881..67c7f5d50e 100644 --- a/types/lib/legacy/mutable-data-behavior.d.ts +++ b/types/lib/legacy/mutable-data-behavior.d.ts @@ -66,8 +66,6 @@ declare namespace Polymer { _shouldPropertyChange(property: string, value: any, old: any): boolean; } - const MutableDataBehavior: object; - /** * Legacy element behavior to add the optional ability to skip strict * dirty-checking for objects and arrays (always consider them to be @@ -130,6 +128,4 @@ declare namespace Polymer { */ _shouldPropertyChange(property: string, value: any, old: any): boolean; } - - const OptionalMutableDataBehavior: object; } diff --git a/types/lib/legacy/templatizer-behavior.d.ts b/types/lib/legacy/templatizer-behavior.d.ts index 81f1df4a2e..cf91f2eb40 100644 --- a/types/lib/legacy/templatizer-behavior.d.ts +++ b/types/lib/legacy/templatizer-behavior.d.ts @@ -111,6 +111,4 @@ declare namespace Polymer { */ modelForElement(el: HTMLElement|null): TemplateInstanceBase|null; } - - const Templatizer: object; } diff --git a/types/lib/mixins/dir-mixin.d.ts b/types/lib/mixins/dir-mixin.d.ts index 58aa8136b9..20f5050395 100644 --- a/types/lib/mixins/dir-mixin.d.ts +++ b/types/lib/mixins/dir-mixin.d.ts @@ -29,7 +29,7 @@ declare namespace Polymer { * - Changing `dir` at runtime is supported. * - Opting out of the global direction styling is permanent */ - function DirMixin {}>(base: T): T & DirMixinConstructor & Polymer.PropertyAccessorsConstructor & Polymer.PropertiesChangedConstructor; + function DirMixin {}>(base: T): T & DirMixinConstructor & Polymer.PropertyAccessorsConstructor; interface DirMixinConstructor { new(...args: any[]): DirMixin; diff --git a/types/lib/mixins/disable-upgrade-mixin.d.ts b/types/lib/mixins/disable-upgrade-mixin.d.ts new file mode 100644 index 0000000000..fe7bbc5ce7 --- /dev/null +++ b/types/lib/mixins/disable-upgrade-mixin.d.ts @@ -0,0 +1,65 @@ +/** + * DO NOT EDIT + * + * This file was automatically generated by + * https://github.com/Polymer/gen-typescript-declarations + * + * To modify these typings, edit the source file(s): + * lib/mixins/disable-upgrade-mixin.html + */ + +declare namespace Polymer { + + + /** + * Element class mixin that allows the element to boot up in a non-enabled + * state when the `disable-upgrade` attribute is present. This mixin is + * designed to be used with element classes like Polymer.Element that perform + * initial startup work when they are first connected. When the + * `disable-upgrade` attribute is removed, if the element is connected, it + * boots up and "enables" as it otherwise would; if it is not connected, the + * element boots up when it is next connected. + * + * Using `disable-upgrade` with Polymer.Element prevents any data propagation + * to the element, any element DOM from stamping, or any work done in + * connected/disconnctedCallback from occuring, but it does not prevent work + * done in the element constructor. + * + * Note, this mixin must be applied on top of any element class that + * itself implements a `connectedCallback` so that it can control the work + * done in `connectedCallback`. For example, + * + * MyClass = Polymer.DisableUpgradeMixin(class extends BaseClass {...}); + */ + function DisableUpgradeMixin {}>(base: T): T & DisableUpgradeMixinConstructor; + + interface DisableUpgradeMixinConstructor { + new(...args: any[]): DisableUpgradeMixin; + } + + interface DisableUpgradeMixin { + attributeChangedCallback(name: any, old: any, value: any): any; + + /** + * NOTE: cannot gate on attribute because this is called before + * attributes are delivered. Therefore, we stub this out and + * call `super._initializeProperties()` manually. + */ + _initializeProperties(): any; + + /** + * prevent user code in connected from running + */ + connectedCallback(): any; + + /** + * prevent element from turning on properties + */ + _enableProperties(): any; + + /** + * only go if "enabled" + */ + disconnectedCallback(): any; + } +} diff --git a/types/lib/mixins/element-mixin.d.ts b/types/lib/mixins/element-mixin.d.ts index d08da7e33d..3d98b8423a 100644 --- a/types/lib/mixins/element-mixin.d.ts +++ b/types/lib/mixins/element-mixin.d.ts @@ -76,7 +76,7 @@ declare namespace Polymer { * `observedAttributes` implementation will automatically return an array * of dash-cased attributes based on `properties`) */ - function ElementMixin {}>(base: T): T & ElementMixinConstructor & Polymer.PropertyEffectsConstructor & Polymer.TemplateStampConstructor & Polymer.PropertyAccessorsConstructor & Polymer.PropertiesChangedConstructor & Polymer.PropertiesMixinConstructor; + function ElementMixin {}>(base: T): T & ElementMixinConstructor & Polymer.PropertyEffectsConstructor & Polymer.PropertiesMixinConstructor; interface ElementMixinConstructor { new(...args: any[]): ElementMixin; diff --git a/types/lib/mixins/properties-changed.d.ts b/types/lib/mixins/properties-changed.d.ts index 13364e1980..02555dcb96 100644 --- a/types/lib/mixins/properties-changed.d.ts +++ b/types/lib/mixins/properties-changed.d.ts @@ -56,7 +56,7 @@ declare namespace Polymer { * * @param name Name of property */ - typeForProperty(name: string): void; + typeForProperty(name: string): any; } interface PropertiesChanged { @@ -84,7 +84,7 @@ declare namespace Polymer { * * @param property Name of the property */ - _addPropertyToAttributeMap(property: string): void; + _addPropertyToAttributeMap(property: string): any; /** * Defines a property accessor for the given property. diff --git a/types/lib/mixins/properties-mixin.d.ts b/types/lib/mixins/properties-mixin.d.ts index 566cd68633..a5ed6a966f 100644 --- a/types/lib/mixins/properties-mixin.d.ts +++ b/types/lib/mixins/properties-mixin.d.ts @@ -53,7 +53,7 @@ declare namespace Polymer { * accessors exist on the element prototype. This method is called by * `finalize` and finalizes the class constructor. */ - _finalizeClass(): void; + _finalizeClass(): any; } interface PropertiesMixin { diff --git a/types/lib/mixins/property-accessors.d.ts b/types/lib/mixins/property-accessors.d.ts index b4c738aca7..186536e1dc 100644 --- a/types/lib/mixins/property-accessors.d.ts +++ b/types/lib/mixins/property-accessors.d.ts @@ -24,14 +24,14 @@ declare namespace Polymer { * For basic usage of this mixin: * * - Declare attributes to observe via the standard `static get observedAttributes()`. Use - * `dash-case` attribute names to represent `camelCase` property names. + * `dash-case` attribute names to represent `camelCase` property names. * - Implement the `_propertiesChanged` callback on the class. - * - Call `MyClass.createPropertiesForAttributes()` **once** on the class to generate - * property accessors for each observed attribute. This must be called before the first + * - Call `MyClass.createPropertiesForAttributes()` **once** on the class to generate + * property accessors for each observed attribute. This must be called before the first * instance is created, for example, by calling it before calling `customElements.define`. * It can also be called lazily from the element's `constructor`, as long as it's guarded so * that the call is only made once, when the first instance is created. - * - Call `this._enableProperties()` in the element's `connectedCallback` to enable + * - Call `this._enableProperties()` in the element's `connectedCallback` to enable * the accessors. * * Any `observedAttributes` will automatically be diff --git a/types/lib/mixins/property-effects.d.ts b/types/lib/mixins/property-effects.d.ts index 572674abe3..da3239df3c 100644 --- a/types/lib/mixins/property-effects.d.ts +++ b/types/lib/mixins/property-effects.d.ts @@ -46,7 +46,7 @@ declare namespace Polymer { * whereas the default when using `PropertyAccessors` standalone is to be * async by default. */ - function PropertyEffects {}>(base: T): T & PropertyEffectsConstructor & Polymer.TemplateStampConstructor & Polymer.PropertyAccessorsConstructor & Polymer.PropertiesChangedConstructor; + function PropertyEffects {}>(base: T): T & PropertyEffectsConstructor & Polymer.TemplateStampConstructor & Polymer.PropertyAccessorsConstructor; interface PropertyEffectsConstructor { new(...args: any[]): PropertyEffects; diff --git a/types/util/minimalDocument.d.ts b/types/util/minimalDocument.d.ts new file mode 100644 index 0000000000..6b08817411 --- /dev/null +++ b/types/util/minimalDocument.d.ts @@ -0,0 +1,13 @@ +/** + * DO NOT EDIT + * + * This file was automatically generated by + * https://github.com/Polymer/gen-typescript-declarations + * + * To modify these typings, edit the source file(s): + * util/minimalDocument.js + */ + +declare class MinimalDocTransform { + _transform(file: any, enc: any, cb: any): any; +}