quasarframework / quasar

Quasar Framework - Build high-performance VueJS user interfaces in record time

Home Page:https://quasar.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect TS type for `markerList` of QSliderSlots

thexeos opened this issue · comments

The type definition for when defining custom QSlider marker labels, defined here:

"type": "Array",
"tsType": "SliderMarkerLabelArrayConfig",

"type": "Array",
"tsType": "SliderMarkerLabelArrayConfig",

Results in an incorrect generated types.

Show generated TS interface
export interface QSliderSlots {
  /**
   * What should the menu display after filtering options and none are left to be displayed; Suggestion: <div>
   * @param scope
   */
  "marker-label": (scope: {
    /**
     * Config for current marker label
     */
    marker: SliderMarkerLabelConfig;
    /**
     * Array of marker label configs
     */
    markerList: SliderMarkerLabelArrayConfig[];
    /**
     * Object with key-value where key is the model and the value is the marker label config
     */
    markerMap: SliderMarkerLabelObjectConfig;
    /**
     * Required CSS classes to be applied to the marker element
     */
    classes: string;
    /**
     * Get CSS style Object to apply to a marker element at respective model value; For perf reasons, use only if requested model value is not already part of markerMap
     * @param value The marker label equivalent model value
     * @returns CSS style Object to apply to a marker element at respective model value
     */
    getStyle: (value: number) => any;
  }) => VNode[];
  /**
   * What should the menu display after filtering options and none are left to be displayed; Suggestion: <div>
   * @param scope
   */
  "marker-label-group": (scope: {
    /**
     * Array of marker label configs
     */
    markerList: SliderMarkerLabelArrayConfig[];
    /**
     * Object with key-value where key is the model and the value is the marker label config
     */
    markerMap: SliderMarkerLabelObjectConfig;
    /**
     * Required CSS classes to be applied to the marker element
     */
    classes: string;
    /**
     * Get CSS style Object to apply to a marker element at respective model value; For perf reasons, use only if requested model value is not already part of markerMap
     * @param value The marker label equivalent model value
     * @returns CSS style Object to apply to a marker element at respective model value
     */
    getStyle: (value: number) => any;
  }) => VNode[];
}

Note how markerList in generated types for both slots is SliderMarkerLabelArrayConfig[]. However, SliderMarkerLabelArrayConfig is already an array of SliderMarkerLabelConfig:

export type SliderMarkerLabelArrayConfig = SliderMarkerLabelConfig[];

So we end up with typeof markerList === SliderMarkerLabelConfig[][].

Thank you.

There is another problem.
Using the example with the correct type leads to Vue: Type Partial<CSSStyleDeclaration> is not assignable to type StyleValue at :style="markerList[val].style".