8000 Unable to parse both tsx and ts · Issue #958 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Unable to parse both tsx and ts #958

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

Closed
bradzacher opened this issue Sep 7, 2019 · 4 comments
Closed

Unable to parse both tsx and ts #958

bradzacher opened this issue Sep 7, 2019 · 4 comments
Labels
bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree

Comments

@bradzacher
Copy link
Member

Moving this out of #890 so that we can have a thread without spamming the thread, as I think I'll need to gather more information.


Comment by @ahuglajbclajep:

*.ts is parsed, but *.tsx, *.js, and *.jsx are not parsed.
In v2.1.0 these were parsed by restarting VSCode as in #864, but in 2.1.1-alpha.4 it always fails (even from the command line).


**tsconfig.json**
{
  "compilerOptions": {
    "target": "es6",
    "module": "esnext", // for dynamic import
    "allowJs": true,
    "jsx": "react",
    "sourceMap": true,
    "outDir": "dist", // for allowJs
    "strict": true,
    "moduleResolution": "node",
    "esModuleInterop": true
  },
  "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"]
}

**.eslintrc**
{
  "parser": "@typescript-eslint/parser",
  "parserOptions": { "project": "./tsconfig.json" },
  "env": { "browser": true, "es6": true, "worker": true }, // for allowJS
  "settings": { "react": { "version": "detect" } },
  "plugins": ["@typescript-eslint", "react-hooks"],
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/recommended-requiring-type-checking",
    "plugin:react/recommended",
    "prettier",
    "prettier/@typescript-eslint",
    "prettier/react"
  ],
  "rules": {
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": "warn",
    "react/prop-types": "off"
  },
  "overrides": [
    {
      "files": ["*.js", "*.jsx"],
      "rules": { "@typescript-eslint/explicit-function-return-type": "off" }
    }
  ]
}

**Example file paths that are throwing errors**
  • src/foo.tsx
    • Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
      The file does not match your project config: src/foo.tsx.
      The file must be included in at least one of the projects provided.
  • src/bar.js
    • Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
      The file does not match your project config: src/bar.js.
      The file must be included in at least one of the projects provided.
  • src/baz.jsx
    • Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
      The file does not match your project config: src/baz.jsx.
      The file must be included in at least one of the projects provided.

Versions

package version
@typescript-eslint/eslint-plugin 2.1.1-alpha.4
@typescript-eslint/parser 2.1.1-alpha.4
TypeScript 3.5.3
node 10.16.3
Visual Studio Code 1.38.0
@bradzacher bradzacher added bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree labels Sep 7, 2019
@ahuglajbclajep ahuglajbclajep mentioned this issue Sep 7, 2019
3 tasks
@ahuglajbclajep
Copy link
ahuglajbclajep commented Sep 7, 2019

In v2.1.1-alpha.7, *.tsx, *.js and *.jsx are also parsed.
However, even if it is *.ts, reloading is required when a file is added or renamed.
repo: https://github.com/ahuglajbclajep/958/tree/canary

@bradzacher
Copy link
Member Author

Ahh. Just to confirm, are you saying that if you run yarn lint - everything works fine?

The problems occur when you add a new file, and then you see a parsing error for that file in vscode?

@ahuglajbclajep
Copy link
ahuglajbclajep commented Sep 7, 2019

are you saying that if you run yarn lint - everything works fine?

Yes.

The problems occur when you add a new file, and then you see a parsing error for that file in vscode?

Yes.

@bradzacher
Copy link
Member Author
bradzacher commented Sep 7, 2019

Ah ha!

Sure, that makes sense.
Unfortunately, we've got a known issue right now we're looking into around this.

The problem is that we don't expand the program as the new file is created.
The tracking task for that is #864

Thanks for reporting!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
Development

No branches or pull requests

2 participants
0