Giter VIP home page Giter VIP logo

Comments (6)

livevsonline avatar livevsonline commented on May 22, 2024 2

@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.

posva avatar posva commented on May 22, 2024 1

Is there something blocking the full type being exported?

Not anymore!

from router.

livevsonline avatar livevsonline commented on May 22, 2024 1

That works and looks like this now:

<script setup lang="ts">
import { RouterView, RouterLink } from "vue-router";
{
  RouterView;
  RouterLink;
}
</script>

from router.

ad-on-is avatar ad-on-is commented on May 22, 2024

@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.

jakobluthman avatar jakobluthman commented on May 22, 2024

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

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.

tony19 avatar tony19 commented on May 22, 2024

FWIW, I cannot reproduce this issue in a newly scaffolded project:

  1. 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
  1. Rename src/App.vue to src/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
  1. Rename the import in src/main.ts:
-import App from './App.vue'
+import App from './App.js'
  1. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.