How to use the vue-tsx-support.componentFactoryOf 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 / componentFactory.tsx View on Github external
function withXXX() {
  const Base = tsx.componentFactoryOf<{ onOk: { value: string } }, { default: { value: string }}>().create({
    props: { foo: { type: String, required: true as true }}
  });
  const Ext = tsx.withNativeOn(Base);
  ;
   console.log(v.value)} />;
   v.value }} />;
   {}} />;
  ;  //// TS2322 | TS2326 | TS2769: 'foo' is missing

}
github wonderful-panda / vue-tsx-support / test / tsc / basic / extend.tsx View on Github external
function by_componentFactory() {
    const Base = vuetsx.componentFactoryOf().create({
        props: {
            foo: String
        },
        computed: {
            someProp(): string {
                return "";
            }
        },
        methods: {
            someMethod() {}
        }
    }, ["foo"]);

    /* add more attributes */
    const Extend = vuetsx.ofType().extendFrom(Base);
    // OK
github wonderful-panda / vue-tsx-support / test / tsc / basic / componentFactory.tsx View on Github external
function componentFactoryOf() {
    const factory = tsx.componentFactoryOf<{ onChange: number, onOk(target: any, id: string): void }, { content: string }>();
    const MyComponent = factory.create({
        props: {
            foo: String,
            bar: Number
        },
        computed: {
            okNode(): VNode {
                return <div>{this.$scopedSlots.content("foo")}</div>;
            },
            ngNode(): VNode {
                return <div>{this.$scopedSlots.content(0)}</div>;       //// TS2345: '0' is not assignable
            }
        },
        render(): VNode {
            return <div>{[this.okNode, this.ngNode]}</div>;
        },
github wonderful-panda / vue-tsx-support / test / tsc / basic / componentFactory.tsx View on Github external
function optionalScopedSlot() {
    const factory = tsx.componentFactoryOf&lt;{}, { required: string, optional?: number }&gt;();
    const MyComponent = factory.create({
        props: {
            foo: String,
            bar: Number
        },
        render(): VNode {
            return (
              <div>
                {this.$scopedSlots.optional!(1)} // OK
                {this.$scopedSlots.optional(1)} //// TS2722: possibly 'undefined'
              </div>
            );
        },
    });

    /* checking type of scopedSlots */
github wonderful-panda / vue-tsx-support / test / jest / componentFactory.tsx View on Github external
it("scoped slot", () =&gt; {
      const ChildComponent = tsx
        .componentFactoryOf&lt;{}, { default: string }&gt;()
        .create({
          props: {
            foo: String
          },
          render(): VNode {
            return <div>{this.$scopedSlots.default(this.foo)}</div>;
          }
        });

      const ParentComponent = tsx.component({
        render(): VNode {
          return (