How to use the vue-tsx-support/lib/vca.component function in vue-tsx-support

To help you get started, we’ve selected a few vue-tsx-support examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wonderful-panda / vue-tsx-support / test / tsc / basic / vca.tsx View on Github external
const MyComponent = component({
  name: "MyComponentName",
  props: {
    foo: String,
    bar: { type: Boolean, required: true }
  },
  setup(props, ctx) {
    return () =&gt; <div class="{props.foo}">{ctx.slots.default()}</div>;
  }
});

; // OK
; // OK
; //// TS2322 | TS2769: 'bar' is missing

const MyComponent2 = component({
  props: {
    foo: String
  },
  setup(
    props,
    ctx: SetupContext&lt;{ onCutstomEvent: string }, { ss: boolean }, { customEvent: string }&gt;
  ) {
    const emitUpdate = updateEmitter();
    const onClick = () =&gt; {
      emit(ctx, "customEvent", "value");
      emitOn(ctx, "onCutstomEvent", "value");

      emit(ctx, "customEvent2", "value"); //// TS2345
      emitOn(ctx, "onCutstomEvent2", "value"); //// TS2345

      emit(ctx, "customEvent", 1); //// TS2345
github wonderful-panda / vue-tsx-support / test / tsc / basic / vca.tsx View on Github external
import { component, SetupContext, emit, emitOn, updateEmitter } from "vue-tsx-support/lib/vca";

const MyComponent = component({
  name: "MyComponentName",
  props: {
    foo: String,
    bar: { type: Boolean, required: true }
  },
  setup(props, ctx) {
    return () =&gt; <div class="{props.foo}">{ctx.slots.default()}</div>;
  }
});

; // OK
; // OK
; //// TS2322 | TS2769: 'bar' is missing

const MyComponent2 = component({
  props: {