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

Remove automatic TypeScript type generation #5653

Merged
merged 3 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ analysis.json

# NPM artifact
polymer-polymer-*.tgz

# Typings are generated upon publish to NPM, except for one.
*.d.ts
!interfaces.d.ts
46 changes: 0 additions & 46 deletions gen-tsd.json

This file was deleted.

213 changes: 213 additions & 0 deletions lib/elements/array-selector.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
// tslint:disable:variable-name Describing an API that's defined elsewhere.
// tslint:disable:no-any describes the API as best we are able today

import {PolymerElement} from '../../polymer-element.js';

import {dedupingMixin} from '../utils/mixin.js';

import {calculateSplices} from '../utils/array-splice.js';

import {ElementMixin} from '../mixins/element-mixin.js';


/**
* Element mixin for recording dynamic associations between item paths in a
* master `items` array and a `selected` array such that path changes to the
* master array (at the host) element or elsewhere via data-binding) are
* correctly propagated to items in the selected array and vice-versa.
*
* The `items` property accepts an array of user data, and via the
* `select(item)` and `deselect(item)` API, updates the `selected` property
* which may be bound to other parts of the application, and any changes to
* sub-fields of `selected` item(s) will be kept in sync with items in the
* `items` array. When `multi` is false, `selected` is a property
* representing the last selected item. When `multi` is true, `selected`
* is an array of multiply selected items.
*/
declare function ArraySelectorMixin<T extends new (...args: any[]) => {}>(base: T): T & ArraySelectorMixinConstructor & ElementMixinConstructor & PropertyEffectsConstructor & TemplateStampConstructor & PropertyAccessorsConstructor & PropertiesChangedConstructor & PropertiesMixinConstructor;

import {ElementMixinConstructor} from '../mixins/element-mixin.js';

import {PropertyEffectsConstructor, PropertyEffects} from '../mixins/property-effects.js';

import {TemplateStampConstructor, TemplateStamp} from '../mixins/template-stamp.js';

import {PropertyAccessorsConstructor, PropertyAccessors} from '../mixins/property-accessors.js';

import {PropertiesChangedConstructor, PropertiesChanged} from '../mixins/properties-changed.js';

import {PropertiesMixinConstructor, PropertiesMixin} from '../mixins/properties-mixin.js';

interface ArraySelectorMixinConstructor {
new(...args: any[]): ArraySelectorMixin;
}

export {ArraySelectorMixinConstructor};

interface ArraySelectorMixin extends ElementMixin, PropertyEffects, TemplateStamp, PropertyAccessors, PropertiesChanged, PropertiesMixin {

/**
* An array containing items from which selection will be made.
*/
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|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;

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

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

/**
* Clears the selection state.
*/
clearSelection(): void;

/**
* Returns whether the item is currently selected.
*
* @param item Item from `items` array to test
* @returns Whether the item is selected
*/
isSelected(item: any): boolean;

/**
* Returns whether the item is currently selected.
*
* @param idx Index from `items` array to test
* @returns Whether the item is selected
*/
isIndexSelected(idx: number): boolean;

/**
* Deselects the given item if it is already selected.
*
* @param item Item from `items` array to deselect
*/
deselect(item: any): void;

/**
* Deselects the given index if it is already selected.
*
* @param idx Index from `items` array to deselect
*/
deselectIndex(idx: number): void;

/**
* Selects the given item. When `toggle` is true, this will automatically
* deselect the item if already selected.
*
* @param item Item from `items` array to select
*/
select(item: any): void;

/**
* Selects the given index. When `toggle` is true, this will automatically
* deselect the item if already selected.
*
* @param idx Index from `items` array to select
*/
selectIndex(idx: number): void;
}

export {ArraySelectorMixin};

/**
* Element implementing the `ArraySelector` mixin, which records
* dynamic associations between item paths in a master `items` array and a
* `selected` array such that path changes to the master array (at the host)
* element or elsewhere via data-binding) are correctly propagated to items
* in the selected array and vice-versa.
*
* The `items` property accepts an array of user data, and via the
* `select(item)` and `deselect(item)` API, updates the `selected` property
* which may be bound to other parts of the application, and any changes to
* sub-fields of `selected` item(s) will be kept in sync with items in the
* `items` array. When `multi` is false, `selected` is a property
* representing the last selected item. When `multi` is true, `selected`
* is an array of multiply selected items.
*
* Example:
*
* ```js
* import {PolymerElement} from '@polymer/polymer';
* import '@polymer/polymer/lib/elements/array-selector.js';
*
* class EmployeeList extends PolymerElement {
* static get _template() {
* return html`
* <div> Employee list: </div>
* <dom-repeat id="employeeList" items="{{employees}}">
* <template>
* <div>First name: <span>{{item.first}}</span></div>
* <div>Last name: <span>{{item.last}}</span></div>
* <button on-click="toggleSelection">Select</button>
* </template>
* </dom-repeat>
*
* <array-selector id="selector"
* items="{{employees}}"
* selected="{{selected}}"
* multi toggle></array-selector>
*
* <div> Selected employees: </div>
* <dom-repeat items="{{selected}}">
* <template>
* <div>First name: <span>{{item.first}}</span></div>
* <div>Last name: <span>{{item.last}}</span></div>
* </template>
* </dom-repeat>`;
* }
* static get is() { return 'employee-list'; }
* static get properties() {
* return {
* employees: {
* value() {
* return [
* {first: 'Bob', last: 'Smith'},
* {first: 'Sally', last: 'Johnson'},
* ...
* ];
* }
* }
* };
* }
* toggleSelection(e) {
* const item = this.$.employeeList.itemForElement(e.target);
* this.$.selector.select(item);
* }
* }
* ```
*/
declare class ArraySelector extends
ArraySelectorMixin(
PolymerElement) {
}

declare global {

interface HTMLElementTagNameMap {
"array-selector": ArraySelector;
}
}

export {ArraySelector};
65 changes: 65 additions & 0 deletions lib/elements/custom-style.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// tslint:disable:variable-name Describing an API that's defined elsewhere.

import {cssFromModules} from '../utils/style-gather.js';

export {CustomStyle};

/**
* Custom element for defining styles in the main document that can take
* advantage of [shady DOM](https://github.com/webcomponents/shadycss) shims
* for style encapsulation, custom properties, and custom mixins.
*
* - Document styles defined in a `<custom-style>` are shimmed to ensure they
* do not leak into local DOM when running on browsers without native
* Shadow DOM.
* - Custom properties can be defined in a `<custom-style>`. Use the `html` selector
* to define custom properties that apply to all custom elements.
* - Custom mixins can be defined in a `<custom-style>`, if you import the optional
* [apply shim](https://github.com/webcomponents/shadycss#about-applyshim)
* (`shadycss/apply-shim.html`).
*
* To use:
*
* - Import `custom-style.html`.
* - Place a `<custom-style>` element in the main document, wrapping an inline `<style>` tag that
* contains the CSS rules you want to shim.
*
* For example:
*
* ```html
* <!-- import apply shim--only required if using mixins -->
* <link rel="import" href="bower_components/shadycss/apply-shim.html">
* <!-- import custom-style element -->
* <link rel="import" href="bower_components/polymer/lib/elements/custom-style.html">
*
* <custom-style>
* <style>
* html {
* --custom-color: blue;
* --custom-mixin: {
* font-weight: bold;
* color: red;
* };
* }
* </style>
* </custom-style>
* ```
*/
declare class CustomStyle extends HTMLElement {

/**
* Returns the light-DOM `<style>` child this element wraps. Upon first
* call any style modules referenced via the `include` attribute will be
* concatenated to this element's `<style>`.
*
* @returns This element's light-DOM `<style>`
*/
getStyle(): HTMLStyleElement|null;
}

declare global {

interface HTMLElementTagNameMap {
"custom-style": CustomStyle;
}
}
51 changes: 51 additions & 0 deletions lib/elements/dom-bind.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// tslint:disable:variable-name Describing an API that's defined elsewhere.

import {PropertyEffects} from '../mixins/property-effects.js';

import {OptionalMutableData} from '../mixins/mutable-data.js';

import {GestureEventListeners} from '../mixins/gesture-event-listeners.js';

import {hideElementsGlobally} from '../utils/hide-template-controls.js';

export {DomBind};

/**
* Custom element to allow using Polymer's template features (data binding,
* declarative event listeners, etc.) in the main document without defining
* a new custom element.
*
* `<template>` tags utilizing bindings may be wrapped with the `<dom-bind>`
* element, which will immediately stamp the wrapped template into the main
* document and bind elements to the `dom-bind` element itself as the
* binding scope.
*/
declare class DomBind extends
PropertyEffects(
OptionalMutableData(
GestureEventListeners(
HTMLElement))) {

/**
* @param name Name of attribute that changed
* @param old Old attribute value
* @param value New attribute value
* @param namespace Attribute namespace.
*/
attributeChangedCallback(name: string, old: string|null, value: string|null, namespace: string|null): void;
connectedCallback(): void;
disconnectedCallback(): void;

/**
* Forces the element to render its content. This is typically only
* necessary to call if HTMLImports with the async attribute are used.
*/
render(): void;
}

declare global {

interface HTMLElementTagNameMap {
"dom-bind": DomBind;
}
}
Loading