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

Functions in propos in mitosis component not transpiled to propfunction in qwik output #1581

Open
1 of 12 tasks
waozixyz opened this issue Oct 3, 2024 · 0 comments
Open
1 of 12 tasks
Labels
bug Something isn't working

Comments

@waozixyz
Copy link

waozixyz commented Oct 3, 2024

I am interested in helping provide a fix!

Yes

Which generators are impacted?

  • All
  • Angular
  • HTML
  • Preact
  • Qwik
  • React
  • React-Native
  • Solid
  • Stencil
  • Svelte
  • Vue
  • Web components

Reproduction case

cannot use tsx?

Expected Behaviour

when i have an interafce witha function such as onChange it needs to transpile to a propfunction in qwik otherwise i get an error and it does not work.

If i am just one component it does not seem to give an error, but if i am relying to multiple mitosis components that are using the onChange prop it stops working and i need to manually update the qwik transpiled code to make it work again

Actual Behaviour

see the message above

Additional Information

Either I am not using mitosis correctly or this is indeed a bug
here the example interafces iamusing

export interface CalendarProps {
  value?: Date;
  onChange?: (event: { target: { value: Date } }) => void;
  minDate?: Date;
  maxDate?: Date;
  backgroundColor?: string;
  textColor?: string;
  accentColor?: string;
  fontSize?: string;
  locale?: string;
}


export interface DateTimePickerProps {
  value?: Date;
  onChange?: (event: { target: { value: Date } }) => void;
  format?: '12h' | '24h';
  size?: 'small' | 'medium' | 'large';
  backgroundColor?: string;
  textColor?: string;
  accentColor?: string;
  showBorder?: boolean;
  minDate?: Date;
  maxDate?: Date;
}

the date timepicker usesthe calendar as well so the onChange method gets called in the date time picker

      {state.isCalendarOpen && (
        <Calendar
          value={state.selectedDateTime}
          onChange={(event) => state.setDate(event)}
          minDate={props.minDate}
          maxDate={props.maxDate}
          accentColor={state.accentColor}
          fontSize={state.fontSize}
          backgroundColor={state.backgroundColor}
          textColor={state.textColor}
        />
      )}

In the qwik output i manually need to update the onChange to be a Propfunction such as this

 import {
  $,
  Fragment,
  PropFunction,
  component$,
  h,
  useStore,
  useStylesScoped$,
  useTask$,
  useVisibleTask$,
} from "@builder.io/qwik";

import { DateTime, Info } from "luxon";

export interface CalendarProps {
  value?: Date;
  onChange$?: PropFunction<(event: { target: { value: Date } }) => void>;
  minDate?: Date;
  maxDate?: Date;
  backgroundColor?: string;
  textColor?: string;
  accentColor?: string;
  fontSize?: string;
  locale?: string;
}

by default this gets generated


import {
  $,
  Fragment,
  component$,
  h,
  useStore,
  useStylesScoped$,
  useTask$,
  useVisibleTask$,
} from "@builder.io/qwik";

import { DateTime, Info } from "luxon";

export interface CalendarProps {
  value?: Date;
  onChange?: (event: {
    target: {
      value: Date;
    };
  }) => void;
  minDate?: Date;
  maxDate?: Date;
  backgroundColor?: string;
  textColor?: string;
  accentColor?: string;
  fontSize?: string;
  locale?: string;
}

which gives an erorr

@waozixyz waozixyz added the bug Something isn't working label Oct 3, 2024
@waozixyz waozixyz changed the title Functions in propos in mitosis component not transpiled topropfunction in qwik output Functions in propos in mitosis component not transpiled to propfunction in qwik output Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant