0
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?

3
  • 2
    Just remove the type annotations? Commented Jun 15, 2022 at 8:25
  • 1
    You could also run it through the TypeScript compiler to get JavaScript! Commented Jun 15, 2022 at 8:29
  • An upvote would also be appreciated! Commented Jun 15, 2022 at 19:55

3 Answers 3

1

Remove the typings. The ':any'

Sign up to request clarification or add additional context in comments.

Comments

0

You can remove ': any' and 'as any' as JavaScript doesn't have data type hints.

Comments

0

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' };
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.