{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react" <=error
},
"include": [
"./src/**/*.ts"
]
}Login.tsx
interface IUserLoginInformation {
username: string;
password: string;
}
const Login = () => {
const {
register,
handleSubmit,
watch,
formState: { errors }
} = useForm<IUserLoginInformation>();
const history = useHistory();
const [users, setUsers] = React.useState([]);
const onSubmit: SubmitHandler<IUserLoginInformation> = data =>
fetchLoginDeatils();
return (
<form onSubmit={handleSubmit(onSubmit)}>
<input defaultValue="test" {...register("username")} />{" "}
{/* register your input into the hook by invoking the "register" function */}
{/* include validation with required or other standard HTML validation rules */}
<input {...register("password", { required: true })} />
{/* errors will return when field validation fails */}
{errors.password && <span>This field is required</span>}
<input type="submit" />
</form>
);
};
export default (Login);在上面的代码中,我得到了以下错误:我在互联网上尝试了所有可能的选项。但是没有什么是changed.In登录代码,我使用javascript和脚本.I更改"jsx":"react-jsx" to "jsx":“put”。
Cannot use JSX unless the '--jsx' flag is provided.发布于 2021-10-03 10:56:57
下面的内容是错误的,因为它排除了.tsx文件,比如Login.tsx
"include": [
"./src/**/*.ts"
]修复
改为:
"include": [
"src"
]附加提示
更改后的
https://stackoverflow.com/questions/69421521
复制相似问题