Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
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
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>;
},
function optionalScopedSlot() {
const factory = tsx.componentFactoryOf<{}, { required: string, optional?: number }>();
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 */
it("scoped slot", () => {
const ChildComponent = tsx
.componentFactoryOf<{}, { default: string }>()
.create({
props: {
foo: String
},
render(): VNode {
return <div>{this.$scopedSlots.default(this.foo)}</div>;
}
});
const ParentComponent = tsx.component({
render(): VNode {
return (