question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TypeScript] LocaleRoute should return Location

See original GitHub issue

Version

nuxt-i18n: 6.12.2 nuxt: 2.13.1

What is the problem ?

From vue-router type definitions:

  • push(location: RawLocation): Promise<Route>
  • replace(location: RawLocation): Promise<Route>

Those methods expect type RawLocation = string | Location but localeRoute from nuxt-i18n returns Route object which is slightly different from Location

Solution expected

  • localeRoute(route: RawLocation, locale?: string): Route | undefined
  • should become localeRoute(route: RawLocation, locale?: string): Location | undefined

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
rchlcommented, Apr 9, 2021

Changed my mind. Leaving localeRoute behavior unchanged and return type changed to reflect the reality (Route), and added localeLocation API that returns Location.

0reactions
rchlcommented, Apr 8, 2021

Changing the return type to Location. I think the primary use case is to use it with router.push but then it’s probably a bit badly named. But too late to change that now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[TypeScript] LocaleRoute should return Location #776 - GitHub
Version nuxt-i18n: 6.12.2 nuxt: 2.13.1 What is the problem ? From vue-router type definitions: push(location: RawLocation): Promise ...
Read more >
Angular: How to redirect to a given url if variable is present in ...
I want that next time if I load the application, it should check to see if ... localePath) { return; } else {...
Read more >
Basic Usage - i18n-module
It works like localePath but returns Location resolved by Vue Router rather than just a full route path. This can be useful since...
Read more >
The Ultimate Vue Localization Guide | Phrase
Dive into Vue localization and learn how to plug the Vue I18n library into your app, so you can make it accessible to...
Read more >
next/router NextRouter TypeScript Examples
This page shows TypeScript code examples of next/router NextRouter. ... window.location.href = url as string; return true; } route = '/'; }. Example...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found