Skip to content

TS Parsing errors #1223

Closed
Closed
@jods4

Description

@jods4

Tell us about your environment

  • ESLint version: 7.3.1
  • eslint-plugin-vue version: 7.0.0-alpha.6
  • @typescript-eslint/eslint-plugin: 3.4.0
  • @typescript-eslint/parser: 3.4.0
  • fork-ts-checker-webpack-plugin: 5.0.5
  • typescript: 3.9.5
  • Node version: 14.4.0

Please show your full configuration:

{
    "extends": [
      "plugin:@typescript-eslint/recommended",
      "plugin:vue/vue3-recommended"
    ],
    "parserOptions": {
      "parser": "@typescript-eslint/parser",
      "ecmaVersion": 2020,
      "sourceType": "module"
    },
    "rules": { "a bunch of rules": "off" }
}

What did you do?

<script lang="ts">
  import { h, FunctionalComponent } from "vue";

  export default <FunctionalComponent<{ header?: string }>>(
    function (props, { slots }) {
      if (props.header) {
        return h("div", { class: "header" }, [
          h("h3", props.header),
          slots.default!({ class: "header-child" }),
        ]);
      }

      const unwrap = slots.default!();
      return unwrap.length == 1 ? unwrap[0] : unwrap;
    }
  );
</script>

What did you expect to happen?
Anything but parsing errors.
This code is valid typescript and compiles fine, but eslint parsing chokes on it with parsing errors (see below).

There are a few other random parsing errors in other files but always in .vue files.
None of those seem related or new syntax. It just doesn't make sense to me.
Everything compiles and runs fine.

Unfortunately there are lots of moving pieces here, as I'm using eslint through fork-ts-checker, and I've got both the typescript and vue plugins layered on top of each other.

I put parser: "@typescript-eslint/parser" in parserOptions, as the docs says.

What actually happened?
This is one example of an error I'm getting:
image

I have a fair amount of complex TS in .ts files as well, but I'm only getting parser errors from .vue files. So I figure something must be wrong when the vue plugin is involved, although I have no idea what or why.

More examples of errors I'm getting:
image

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions