function PrivateRoute({ children } : any ) {
const accessToken = false;
const loading = false;
const navigate = useNavigate();
const location = useLocation();
const fromLocation = (location.state as any)?.from;
const previousLocation = location.state ? fromLocation : { pathname: '/login' };
How to transform two lines of code with 'any' keyword to javascript code?
CodePudding user response:
You can remove ': any
' and 'as any
' as JavaScript doesn't have data type hints.
CodePudding user response:
Try this
function PrivateRoute(_a) {
var _b;
var children = _a.children;
var accessToken = false;
var loading = false;
var navigate = useNavigate();
var location = useLocation();
var fromLocation = (_b = location.state) === null || _b === void 0 ? void 0 : _b.from;
var previousLocation = location.state ? fromLocation : { pathname: '/login' };
}
CodePudding user response:
Remove the typings. The ':any'