8000 intellisense bugs in *.vue SFC with lang=tsx · Issue #569 · vuejs/vetur · GitHub
[go: up one dir, main page]

Skip to content
intellisense bugs in *.vue SFC with lang=tsx #569
@Plasmatium

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0