Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No intellisense support in visual studio code. Suggestion for possible solution #1

Closed
jclijmans opened this issue Apr 1, 2017 · 1 comment

Comments

@jclijmans
Copy link
Collaborator

Hi Paul,

Nice work, I was looking for a typescript implementation and found this, thanks.
I've got one issue: I don't get intellisense support for typescript inside the script tags of a .vue file.
Without intellisense, I make too many errors, so this annoyed me.
The vscode team has no plans yet to include support for imported variables, see #15377

I've got a possible solution, but for this we need to create a separate .ts file

  • Create a separate .ts file to hold your component's typescript code , for example Index.ts
    @Component({ props: { propMessage: String } }) export default class Index extends Vue { ....
    In your Index.vue file make your script tag like this
<script lang="ts"> import Index from './Index.ts' export default Index </script>

We can now import this vue file in some other component code or router, just like it would be a single file

Now inside the .ts file, I get my intellisense.
If you've got another suggestion to get intellisense working inside the .vue file, I would be very glad to know.

@paulvanbladel
Copy link
Owner

paulvanbladel commented Apr 1, 2017

Indeed, I'm using that approach in my projects.

I always start with just one file and try to split components in sub components and so on.
By doing so, I have a lot of 'dump' components that actually don't need any backing .ts file at all.
But indeed, when a lot of typescript code pops up, I delegate the code to a dedicated ts file with the technique you suggest as well.
Pragmatism rules :)
Check also this approach without .vue files:
https://github.com/ducksoupdev/vue-webpack-typescript

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants