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

feat: prepare for TS defs generation #150

Merged
merged 7 commits into from
May 29, 2020
Merged

feat: prepare for TS defs generation #150

merged 7 commits into from
May 29, 2020

Conversation

pekam
Copy link
Contributor

@pekam pekam commented May 28, 2020

Closes #141

Generated TS definitions look like this:

vaadin-time-picker.d.ts

(updated)

import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {ThemableMixin} from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
import {ElementMixin} from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
import {IronA11yKeysBehavior} from '@polymer/iron-a11y-keys-behavior/iron-a11y-keys-behavior.js';
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
import {ControlStateMixin} from '@vaadin/vaadin-control-state-mixin/vaadin-control-state-mixin.js';

declare class TimePickerElement extends
  ElementMixin(
  ControlStateMixin(
  ThemableMixin(
  PolymerElement))) {

  readonly focusElement: HTMLElement;
  disabled: boolean;
  name: string|null|undefined;
  value: string;
  label: string|null|undefined;
  required: boolean;
  preventInvalidInput: boolean|null|undefined;
  pattern: string|null|undefined;
  errorMessage: string|null|undefined;
  placeholder: string;
  readonly: boolean;
  invalid: boolean;
  min: string;
  max: string;
  step: number|null|undefined;
  clearButtonVisible: boolean;
  autoOpenDisabled: boolean|null|undefined;
  i18n: TimePickerI18n;
  ready(): void;
  validate(): boolean;
  _timeAllowed(time: TimePickerTime): boolean;
  checkValidity(): boolean;
}

declare global {

  interface HTMLElementTagNameMap {
    "vaadin-time-picker": TimePickerElement;
  }
}

export {TimePickerElement};
import {TimePickerI18n} from '../@types/interfaces';
import {TimePickerTime} from '../@types/interfaces';

Comment on lines +627 to 630
/** @private */
_getInputElement() {
return this.shadowRoot.querySelector('vaadin-time-picker-text-field');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure what to do with this. I feel like this _getInputElement should be private and the __inputElement getter below should be protected, but their number of underscores implies the exact opposite. So now they're both private.

.npmignore Outdated Show resolved Hide resolved
@pekam pekam requested review from Haprog and web-padawan May 28, 2020 15:02
Copy link
Member

@web-padawan web-padawan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add @type {string} for placeholder, min and max properties.

@types/interfaces.d.ts Outdated Show resolved Hide resolved
src/vaadin-time-picker.html Outdated Show resolved Hide resolved
src/vaadin-time-picker.html Outdated Show resolved Hide resolved
@types/interfaces.d.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Haprog Haprog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Properties value, placeholder, min, max should have @type {string}
  2. Double underscored properties/methods should have explicit @private: __dropdownItems, __validDayDivisor(), __onKeyDown(), __onArrowPressWithStep(), __dispatchStep(), __getMsec(), __getSec(), __addStep(), __updateDropdownItems(), __generateDropdownList(), __adjustValue(), __valueChanged(), __onInputChange(), __updateValue(), __updateInputValue(), __validateTime(), __getStepSegment(), __formatISO(), __parseISO(), __inputElement(), __dropdownElement()
  3. Single underscored properties/methods should have explicit @protected: ready()

src/vaadin-time-picker.html Show resolved Hide resolved
@web-padawan web-padawan merged commit 59ab041 into master May 29, 2020
@web-padawan web-padawan deleted the gen-ts-defs branch May 29, 2020 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate TypeScript definitions for P3
3 participants