Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Hello World!;
/*
* Hooks API
*/
const [location, setLocation] = useLocation();
location; // $ExpectType string
setLocation(); // $ExpectError
setLocation("/app");
setLocation("/app", true);
useLocation({ base: "/app" }); // $ExpectError
useRoute(Symbol()); // $ExpectError
useRoute(); // $ExpectError
useRoute("/");
const [match, params] = useRoute<{ id: string }>("/app/users/:id");
match; // $ExpectType boolean
if (params) {
params.id; // $ExpectType string
params.age; // $ExpectError
} else {
params; // $ExpectType null
}
const [, parameters] = useRoute<{ id: string }>("/app/users/:id");
if (parameters) {
/*
* Hooks API
*/
const [location, setLocation] = useLocation();
location; // $ExpectType string
setLocation(); // $ExpectError
setLocation("/app");
setLocation("/app", true);
useLocation({ base: "/app" }); // $ExpectError
useRoute(Symbol()); // $ExpectError
useRoute(); // $ExpectError
useRoute("/");
const [match, params] = useRoute<{ id: string }>("/app/users/:id");
match; // $ExpectType boolean
if (params) {
params.id; // $ExpectType string
params.age; // $ExpectError
} else {
params; // $ExpectType null
}
const [, parameters] = useRoute<{ id: string }>("/app/users/:id");
if (parameters) {
parameters.id; // $ExpectType string
parameters.age; // $ExpectError
useRoute(Symbol()); // $ExpectError
useRoute(); // $ExpectError
useRoute("/");
const [match, params] = useRoute<{ id: string }>("/app/users/:id");
match; // $ExpectType boolean
if (params) {
params.id; // $ExpectType string
params.age; // $ExpectError
} else {
params; // $ExpectType null
}
const [, parameters] = useRoute<{ id: string }>("/app/users/:id");
if (parameters) {
parameters.id; // $ExpectType string
parameters.age; // $ExpectError
} else {
parameters; // $ExpectType null
}