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 #39

Merged
merged 1 commit into from
May 29, 2020
Merged

feat: prepare for TS defs generation #39

merged 1 commit into from
May 29, 2020

Conversation

Haprog
Copy link
Contributor

@Haprog Haprog commented May 29, 2020

Fixes #35

Generated TS definitions look like this:

@types/interfaces.d.ts

import { DatePickerI18n } from '@vaadin/vaadin-date-picker/@types/interfaces';
import { TimePickerI18n } from '@vaadin/vaadin-time-picker/@types/interfaces';

export interface DateTimePickerI18n extends DatePickerI18n, TimePickerI18n {}

vaadin-date-time-picker.d.ts

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

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

import {ThemableMixin} from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';

import {html} from '@polymer/polymer/lib/utils/html-tag.js';

declare class DateTimePicker extends
  ElementMixin(
  ThemableMixin(
  PolymerElement)) {

  name: string|null|undefined;
  invalid: boolean;
  required: boolean;
  errorMessage: string|null|undefined;
  value: string;
  min: string|undefined;
  max: string|undefined;
  datePlaceholder: string|null|undefined;
  timePlaceholder: string|null|undefined;
  step: number|null|undefined;
  initialPosition: string|null|undefined;
  showWeekNumbers: boolean|null|undefined;
  label: string;
  autoOpenDisabled: boolean|null|undefined;
  disabled: boolean;
  readonly: boolean;
  autofocus: boolean;
  i18n: DateTimePickerI18n;

  ready(): void;
  focus(): void;
  validate(): boolean;
  checkValidity(): boolean;
}

declare global {
  interface HTMLElementTagNameMap {
    "vaadin-date-time-picker": DateTimePicker;
  }
}

export {DateTimePicker};

import {DateTimePickerI18n} from '../@types/interfaces';

@Haprog Haprog requested a review from web-padawan May 29, 2020 10:15
Comment on lines +81 to +87
/**
* @typedef {object} TimePickerTime
* @property {string | number} hours
* @property {string | number} minutes
* @property {string | number} [seconds]
* @property {string | number} [milliseconds]
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not needed for TS defs, but I added it as a convenience so that the IDE can help with this type even when working with the Polymer 2 sources since TimePickerTime is used internally.

@Haprog
Copy link
Contributor Author

Haprog commented May 29, 2020

I checked that the visual test failures already affect master so not broken by this PR. Problem is RTL style updates in date-picker and some issue with date picker border radius only affecting Lumo version. I'll make a separate PR for fixing those.

@Haprog Haprog merged commit 0d73647 into master May 29, 2020
@Haprog Haprog deleted the gen-ts-defs branch May 29, 2020 12:00
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
2 participants