diff --git a/types/polymer/index.d.ts b/types/polymer/index.d.ts index 1b67f4c6d5..0691c8506f 100644 --- a/types/polymer/index.d.ts +++ b/types/polymer/index.d.ts @@ -20,19 +20,17 @@ declare global { observer?: string; } - interface Base { - /** Need to allow all properties for callback methods. */ - [prop: string]: any; - + interface CommonBase { /* polymer-micro */ // Attributes - hostAttributes?: {[name:string]:any}; + hostAttributes?: {[name: string]: any}; reflectPropertiesToAttribute?(name: string): void; - serializeValueToAttribute?(value: any, attribute: string, node?: Element): void; + serializeValueToAttribute? + (value: any, attribute: string, node?: Element): void; deserialize?(value: string, type: NumberConstructor): number; deserialize?(value: string, type: BooleanConstructor): boolean; @@ -120,7 +118,8 @@ declare global { notifyPath?(path: string, value: any, fromAbove: any): void; - set?(path: string|(string|number)[], value: Value, root?: Object): void; + set?(path: string|(string|number)[], value: Value, root?: Object): + void; get?(path: string|(string|number)[], root?: Object): any; @@ -139,7 +138,8 @@ declare global { unshift?(path: string, ...item: any[]): number; - notifySplices?(path: string, splices: ReadonlyArray): void; + notifySplices? + (path: string, splices: ReadonlyArray): void; // ResolveUrl @@ -155,8 +155,6 @@ declare global { toggleClass?(name: string, bool?: boolean, node?: HTMLElement): void; - toggleAttribute?(name: string, bool?: boolean, node?: HTMLElement): void; - classFollows?(name: string, toElement: HTMLElement, fromElement: HTMLElement): void; attributeFollows?(name: string, toElement: HTMLElement, fromElement: HTMLElement): void; @@ -220,7 +218,19 @@ declare global { detached?(): void; attributeChanged?(name: string, oldValue: any, newValue: any): void; + } + // This is the type of a Polymer element after it has gone through the + // Polymer() function. + interface PolymerElement extends CommonBase, HTMLElement {} + + interface Base extends CommonBase { + /** Need to allow all properties for callback methods. */ + [prop: string]: any; + + // Has to live on Base because it is incompatible with + // HTMLElement#toggleAttribute + toggleAttribute?(name: string, bool?: boolean, node?: HTMLElement): void; } interface DomApiStatic { diff --git a/types/polymer/polymer-tests.ts b/types/polymer/polymer-tests.ts index ce55ac325d..774ae6d8ad 100644 --- a/types/polymer/polymer-tests.ts +++ b/types/polymer/polymer-tests.ts @@ -51,14 +51,14 @@ Polymer({ } }); -var MyElement = Polymer.Class({ +var MyElement = Polymer.Class({ is: 'my-element', created: function () { this.textContent = 'My element!'; } -}); +} as polymer.Base); document.registerElement('my-element', MyElement);