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

intellisense bugs in *.vue SFC with lang=tsx #569

Closed
3 tasks done
Plasmatium opened this issue Dec 4, 2017 · 2 comments
Closed
3 tasks done

intellisense bugs in *.vue SFC with lang=tsx #569

Plasmatium opened this issue Dec 4, 2017 · 2 comments
Labels

Comments

@Plasmatium
Copy link

Plasmatium commented Dec 4, 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

Problem

I tried to use *.vue with `<script lang="tsx"> for SFC, and located a bug(may be) in ts-loader, and issued a PR to fix it. Demo for test is running well.

But there has been some of intellisense and highlight issues:

  // if use lang=tsx, the "string" type notation is not highlight, 
  //and this.msg can't be derived to a string type

  // if use lang=ts, hightlight and type derivation works well, 
  // but this.msg alone is still derived as any and cause an error,
  // and jsx syntax is not allowed in lang=ts
  computed: {
    testMsg: function ():string {
      return (this as any).msg + ' powered by typescript & tsx'
    }
  },

And in render function, data and computed and maybe others all can't be found on this.

Another problem is that, I wrote a jsx.d.ts:

// ./src/types/jsx.d.ts
import Vue, { VNode } from 'vue'

declare global {
  namespace JSX {
    interface Element extends VNode {}
    interface ElementClass extends Vue {}
    interface ElementAttributesProperty {
      $props: {}
    }

    interface IntrinsicElements {
      [elemName: string]: any
    }
  }
}

But that seems like only take an effect on *.tsx files, not on *.vue's <script lant="tsx"> region, I had to write above code again in *.vue. This may not be a bug on vetur, but I can't figure out a way to resolve it.

Reproducible Case

Test this demo repo.

@HerringtonDarkholme
Copy link
Member

And in render function, data and computed and maybe others all can't be found on this.

This is caused by cyclic dependency. Please refer to https://vuejs.org/v2/guide/typescript.html#Annotating-Return-Types

if use lang=tsx, the "string" type notation is not highlight

screen shot 2017-12-05 at 11 18 32 am

But that seems like only take an effect on *.tsx files, not on *.vue's <script lant="tsx"> region

I think you need to reload vscode. This is probably a duplicate of #355 .

@Plasmatium
Copy link
Author

Thanks for your reply, @HerringtonDarkholme

if use lang=tsx, the "string" type notation is not highlight.
I mean the notation : string, not the string content its self. It is brown in my editor under lang=ts, and white under lang=tsx. Finally I found it is the theme problem with different TM scope between lang=tsx and lang=ts

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

2 participants