Skip to content

Compiled code contain jsx code. #54411

Description

@IvanovRoman

Bug Report

Compiled code contain jsx code <Label label='aaaa'/>

🔎 Search Terms

🕗 Version & Regression Information

Typescript version 5.1.0-beta

⏯ Playground Link

Playground link with problem code

Playground link with work code

💻 Code

import*asReactfrom'react';constLabel: React.FC<{label: string;}>=props=><label>{props.label}</label>;interfaceBindProps<T=any,KextendskeyofT=any>{bObject: T;
bKey: K;
bLabel?: string|React.ReactNode;}functionbind<T,KextendskeyofT>(bObject: T,bKey: K,bLabel?: string|React.ReactNode): BindProps<T,K>{return{ bObject, bKey, bLabel };}functionwithBind<Pextendsobject,VextendskeyofP,CextendskeyofP>(Component: React.ComponentType<P>,pick: (value: P[V],onChange: (value: P[V])=>void)=>Pick<P,V|C>){returnclassextendsReact.Component<Omit<P,V|C>&BindProps>{privateonChange=()=>{};render(){const{ bObject, bKey, bLabel, ...rest}=this.props;constprops={ ...pick(bObject[bKey],this.onChange), ...rest}asP;constelement=<Component{...props}/>;if(bLabel===undefined){returnelement;}return(<>{typeofbLabel==='string' ? <Labellabel={bLabel}/> : bLabel}{element}</>);}}}interfaceTextInputProps{value: string;onChange: React.ChangeEventHandler<HTMLInputElement>;}constTextInput: React.FC<TextInputProps>=props=><inputtype='text'{...props}/>;exportconstBTextInput=withBind<TextInputProps,'value','onChange'>(TextInput,(value,onChange)=>{return{ value,onChange: e=>onChange(e.currentTarget.value)};});constobj={text: ''};<BTextInput{...bind(obj,'text',<Labellabel='aaaa'/>)}/>;

🙁 Actual behavior

React.createElement(exports.BTextInput,Object.assign({},bind(obj,'text',<Labellabel='aaaa'/>)));

🙂 Expected behavior

React.createElement(exports.BTextInput,Object.assign({},bind(obj,'text',React.createElement(Label,{label: 'aaaa'}))));

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions