Comments (6)
@posva Do not seem to be fixed for me?
I just installed Vue 3 and am testing out type hinting with vue-tsc
package, and I am now getting this error? Its a totally fresh project with Vue 3.2
from router.
Is there something blocking the full type being exported?
Not anymore!
from router.
That works and looks like this now:
<script setup lang="ts">
import { RouterView, RouterLink } from "vue-router";
{
RouterView;
RouterLink;
}
</script>
from router.
@posva Do not seem to be fixed for me?
I just installed Vue 3 and am testing out type hinting with
vue-tsc
package, and I am now getting this error? Its a totally fresh project with Vue 3.2
Same here, did you find any solution?
from router.
@posva Do not seem to be fixed for me?
I just installed Vue 3 and am testing out type hinting withvue-tsc
package, and I am now getting this error? Its a totally fresh project with Vue 3.2Same here, did you find any solution?
You can import RouterView and RouterLink from vue-router and define them as components in your component, which will give you correct typings and resolve the errors you are getting.
//
import { RouterView, RouterLink } from 'vue-router'
//
components: {
RouterView,
RouterLink
}
Do note that this is not a permanent fix, just a workaround.
from router.
FWIW, I cannot reproduce this issue in a newly scaffolded project:
- Scaffold Vue 3 + Vue Router + TypeScript + JSX, and install deps:
npm init vue vue3-router-ts-1 # select TypeScript, JSX, and Router options at prompt
cd vue3-router-ts-1
pnpm i
- Rename
src/App.vue
tosrc/App.tsx
, and replace its contents with the equivalent JSX:
import { RouterLink, RouterView } from 'vue-router'
import HelloWorld from '@/components/HelloWorld.vue'
function App() {
return <>
<header>
<img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />
<div class="wrapper">
<HelloWorld msg="You did it!" />
<nav>
<RouterLink to="/">Home</RouterLink>
<RouterLink to="/about">About</RouterLink>
</nav>
</div>
</header>
<RouterView />
</>
}
export default App
- Rename the import in
src/main.ts
:
-import App from './App.vue'
+import App from './App.js'
- Run the type checking script:
pnpm type-check
The output shows no errors:
$ pnpm type-check
> [email protected] type-check /Users/tony/src/tmp/vue3-router-ts-1
> vue-tsc --noEmit
$
I also could not reproduce the issue using the above steps without the JSX option and without any changes to the scaffolded code. What steps am I missing?
from router.
Related Issues (20)
- An option to remove vue-router banner from the final bundle HOT 4
- The route rolls back when it is first loaded 路由回退
- Empty error message in production environment when using ESM build HOT 4
- Disable URL hash encoding or whitelist some symbols to make VueRouter work fine with Telegram WebApps HOT 2
- When update the page show message warning when it use vue router dynamically HOT 1
- Custom Query Parsing Doesn't Mesh Well With Typescript HOT 3
- 关于beforeRouteLeave是否可以访问this的问题
- A way to detect if user has history on current site HOT 3
- Ability to check if a router has any pages to go back/forward to HOT 1
- Regex in params extract extra characters with any capturing groups HOT 1
- Optional path segments HOT 4
- Router instance not found when testing component library integration
- hash decode not match the later encode HOT 2
- Inconsistent trailing slash behaviour with multiple optional parameters HOT 5
- router.push with alias not changing original URL HOT 1
- Route Grouping HOT 1
- createMemoryHistory and createWebHistory differs with base HOT 1
- Optional parameters type missmatch on push and popstate back navigation HOT 1
- Default child not shown when using router-link with name instead of path HOT 3
- router.resolve doesn't include details of the query since 4.3.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from router.