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
Clarify relation to the typescript package #2051
Comments
Does the explanation in our readme not do a good enough job here?
https://github.com/typescript-eslint/typescript-eslint#supported-typescript-version It is on purpose we don't want to install an extra version of TS accidentally (multiple versions of TS cause weird hard to reproduce errors).
We have an optional peer dependency because we don't want packages and tools (such as create-react-app) that optionally use our tooling to throw warnings to users about TS versions. We leverage runtime validation of the TS version instead of install time validation for a few reasons:
OOC - as a consumer of the tooling, why does this matter to you?
No, for a few reasons. First, we don't want people to conceptually confuse linting and type checking. Primarily TS's typechecking is about the correctness of your application - the things it reports should indicate incorrect types that will break at runtime. Second, it would be very slow doing it in a lint rule. We use different compiler APIs to that of OTOH, |
Thank you for the quick yet thorough reply to my questions!
I gave the documentation another read through trying to analyse why it wasn't clear to me. One issue might be that TypeScript the language and TypeScript the Compiler are not the same anymore in a project using Create-React-App / Babel. Type checking and type inference are not explicitly mentioned in the main README or the typed linting page. Then there was talk of a custom parser and the I tried to clarify these in my pull request (#2081).
Ideally, as a user, I wouldn't need to understand these differences, but they can cause confusion when everything doesn't work as expected. More ideally, the users would understand these differences so they would have a better grasp of their tooling and could better contribute in the community.
These reasons make perfect sense, but at first I would expect that installing a package would pull in everything necessary, or at least the getting started documentation would tell me how to get there. In #2081, I add
If I understand your response right, it might be possible but not desirable?
Isn't the README making the opposite case though, presenting ESLint and TSC both as (complementary) static analysis tools on top of JavaScript? Traditionally, type checking would be something that the compiler does - unfortunately, Babel doesn't. So we are left with separately running TSC, which is not something all tooling is prepared for. Then, having a rule "type check should pass" included in ESLint would be practical to fill in for Babel and also for pre-commit hooks etc.
I would be very interested in testing and seeing the numbers, especially now that I've learned that the TSC parsing will run twice as well. ( BTW, I noticed this might need clarification wrt laziness on the typed linting page: "by including
In a Babel project, the CI/CD looks something like this:
It still looks to me like the easiest way to simplify and speed this up would be to add an ESLint rule that would make sure all types would be checked, and then step 2 could be skipped. Anyway, I think this could warrant an FAQ entry because I'm not the first one to be puzzled and asking about this. On the long run, if all these tools would work as plugins on the same AST (ESTree?) like Prettier is available as an ESLint plugin now, one parse could be enough and there could be an incremental watch mode too? |
For a fresh perspective from someone new to TypeScript but has prior ESLint experience I took a peek at the docs and quickly started getting dizzy. There's just so much in here getting set-up I'd wager is going to be copypasta for most unless they're really procrastinating. I took a barebones Gatsby site I created today from scratch with only 4 deps, added one React component and TypeScript then tried this setup probably now outdated setup approach and... Running lint takes 6 seconds with one component in my project. Is that normal? Also, I also stumbled on the I feel the docs could benefit greatly from a Recipies section where individuals can show off their various configurations. It seems a lot saner than following a going-on 2 year-old blog post to get set-up or trying to eagle-eye one's way through the docs as they are today. These are my unabashed thoughs. Please take them with a grain of salt. |
@balibebas - have you checked out our getting started guide? That is intended to be the "this is how you set it up in your codebase" doc that talks through the setup and why everything exists. |
Great. Hadn't seen that yet. Will give it a look soon. Thanks, @bradzacher. |
Something of a continuation to #2043 in understanding and documenting more of
@typescript-eslint
's relation totypescript
:In
package.json
,typescript
is marked as an optional peer dependency, but it seems to be obligatory astsutils
fails to load without it. (Worth a comment in README?)Further, if I use the
"plugin:@typescript-eslint/recommended-requiring-type-checking"
rules, who does the type checking? I would assumetypescript
, but it's not clear to me. (Worth a comment in README?)Even further, would it be possible to create a new rule that would report type checking errors? Currently, the separate
tsc --noEmit
must be duplicating some if not all type checking work. (Worth a comment in FAQ?)Repro
Versions
@typescript-eslint/eslint-plugin
2.29.0
@typescript-eslint/parser
2.29.0
ESLint
6.8.0
node
10.19.0
The text was updated successfully, but these errors were encountered: