Skip to content

Commit

Permalink
Update types.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Oct 31, 2018
1 parent 763e40d commit 7f2fcb1
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 10 deletions.
20 changes: 19 additions & 1 deletion externs/closure-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -1412,4 +1412,22 @@ Polymer_DisableUpgradeMixin.prototype.connectedCallback = function(){};
/**
* @override
*/
Polymer_DisableUpgradeMixin.prototype.disconnectedCallback = function(){};
Polymer_DisableUpgradeMixin.prototype.disconnectedCallback = function(){};
/**
* @interface
*/
function Polymer_LegacyDataMixin(){}
/**
* @param {string} property Property that should trigger the effect
* @param {string} type Effect type, from this.PROPERTY_EFFECT_TYPES
* @param {Object=} effect Effect metadata object
* @return {void}
*/
Polymer_LegacyDataMixin.prototype._addPropertyEffect = function(property, type, effect){};
/**
* @param {Object} templateInfo Template metadata to add effect to
* @param {string} prop Property that should trigger the effect
* @param {Object=} effect Effect metadata object
* @return {void}
*/
Polymer_LegacyDataMixin._addTemplatePropertyEffect = function(templateInfo, prop, effect){};
53 changes: 44 additions & 9 deletions types/lib/legacy/legacy-data-mixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,56 @@
*/

/// <reference path="class.d.ts" />
/// <reference path="../polymer.d.ts" />
/// <reference path="../utils/mixin.d.ts" />

declare class UndefinedArgumentError {
constructor(message: any);
declare class UndefinedArgumentError extends Error {
constructor(message: any, arg: any);
}

declare class LegacyDataMixin {
declare namespace Polymer {


/**
* Overrides `Polyer.PropertyEffects` to wrap effect functions to
* catch `UndefinedArgumentError`s and warn.
* Mixin to selectively add back Polymer 1.x's `undefined` rules
* governing when observers & computing functions run based
* on all arguments being defined (reference https://www.polymer-project.org/1.0/docs/devguide/observers#multi-property-observers).
*
* When loaded, all legacy elements (defined with `Polymer({...})`)
* will have the mixin applied. The mixin only restores legacy data handling
* if `_legacyUndefinedCheck: true` is set on the element's prototype.
*
* @param property Property that should trigger the effect
* @param type Effect type, from this.PROPERTY_EFFECT_TYPES
* @param effect Effect metadata object
* This mixin is intended for use to help migration from Polymer 1.x to
* 2.x+ by allowing legacy code to work while identifying observers and
* computing functions that need undefined checks to work without
* the mixin in Polymer 2.
*/
_addPropertyEffect(property: string, type: string, effect?: object|null): void;
function LegacyDataMixin<T extends new (...args: any[]) => {}>(base: T): T & LegacyDataMixinConstructor;

interface LegacyDataMixinConstructor {
new(...args: any[]): LegacyDataMixin;

/**
* Overrides `Polyer.PropertyEffects` to wrap effect functions to
* catch `UndefinedArgumentError`s and warn.
*
* @param templateInfo Template metadata to add effect to
* @param prop Property that should trigger the effect
* @param effect Effect metadata object
*/
_addTemplatePropertyEffect(templateInfo: object|null, prop: string, effect?: object|null): void;
}

interface LegacyDataMixin {

/**
* Overrides `Polyer.PropertyEffects` to wrap effect functions to
* catch `UndefinedArgumentError`s and warn.
*
* @param property Property that should trigger the effect
* @param type Effect type, from this.PROPERTY_EFFECT_TYPES
* @param effect Effect metadata object
*/
_addPropertyEffect(property: string, type: string, effect?: object|null): void;
}
}

0 comments on commit 7f2fcb1

Please sign in to comment.