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

attribute lang="ts" breaks IntelliSense #564

Closed
3 tasks done
lmk123 opened this issue Nov 29, 2017 · 4 comments
Closed
3 tasks done

attribute lang="ts" breaks IntelliSense #564

lmk123 opened this issue Nov 29, 2017 · 4 comments
Labels

Comments

@lmk123
Copy link

lmk123 commented Nov 29, 2017

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: macOS
  • Vetur version: 0.11.3
  • VS Code version: 1.18.1

Vanilla VSCode, with only Vetur enabled.

Problem

It's exactly the same as #111, but it's in the lastest VS Code and Vetur.

Reproducible Case

Open Counter.vue in Veturpack.

If no lang is added, completion works:

image

However, lang="ts" breaks this.

image

@HerringtonDarkholme
Copy link
Member

https://vuejs.org/v2/guide/typescript.html#Basic-Usage

To let TypeScript properly infer types inside Vue component options, you need to define components with Vue.component or Vue.extend

@HerringtonDarkholme
Copy link
Member

For the curious:

We used to wrap TypeScript component export in Vue.extend call in order to get semantic completion. However, it turned to be problematic for other tools like ts-loader where no (enough) special operation is done for Vue SFC. For example, accessing properties on this will trigger errors in ts-loader if noImplicitThis is set, but Vetur requires that flag to provide completion.

So we remove auto wrapping in TS and users have to provide wrapping themselves.

@mitchell-garcia
Copy link

mitchell-garcia commented Dec 8, 2017

@HerringtonDarkholme Is the issue with intellisense missing in Vue.extend resolvable? If not, how do we wrap the component ourselves? Is it recommended we migrate to class-style components to get type-safety in .vue files? Thanks!

@HerringtonDarkholme
Copy link
Member

@mmitchellgarcia You can always wrap component option in Vue.extend manually. noImplicitThis will type check your option object.

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

No branches or pull requests

3 participants