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

Feature: Allow ignore all error codes from file paths #19

Open
Kolobok12309 opened this issue Jul 5, 2023 · 7 comments
Open

Feature: Allow ignore all error codes from file paths #19

Kolobok12309 opened this issue Jul 5, 2023 · 7 comments

Comments

@Kolobok12309
Copy link

I think that would be usefull to ignore all error codes from paths, TS has a lot of codes and update ignored-error-codes.json every time is not very comfortable

It can be argument to cli that reassign --ignored-error-codes

@Gelio
Copy link
Owner

Gelio commented Jul 12, 2023

Thanks for suggesting a feature. This tool was written to ignore only specific strictness-related error codes, not all errors from some files. Can you tell me what is your use case to ignore all errors in a given file? What type of file is that? Why do you need to ignore it entirely in typechecking instead of fixing it?

@Kolobok12309
Copy link
Author

Kolobok12309 commented Jul 12, 2023

Thanks for suggesting a feature. This tool was written to ignore only specific strictness-related error codes, not all errors from some files. Can you tell me what is your use case to ignore all errors in a given file? What type of file is that? Why do you need to ignore it entirely in typechecking instead of fixing it?

We have library written (self-written) in ts and without compiling to .js and .d.ts, this library support two versions of vue and nuxt, and their has different types, that switching by some compile/loader/magic comments while final build of application. Library has typecheck in ci, but in project that has errors.

And skipLibCheck and exclude not worked for it.

@Gelio
Copy link
Owner

Gelio commented Jul 12, 2023

I see. In this case, have you considered writing the library in JavaScript, if you don't need the typechecking?

Anyway, it seems worth migrating to a different config format for V2 of this library. The new format should support ignoring all errors in a given path. I don't have any concrete plans when it will come out, though.

@Kolobok12309
Copy link
Author

Kolobok12309 commented Jul 12, 2023

We need typecheck and use it, but different versions of postcss, webpack, vue, nuxt etc Adding us headache

Okay) You tool really for more strict cases, we already write small script to our needs.

@olafurkarl
Copy link

I would also find such a feature useful.
My use case is that I'm writing a pre-commit hook, which should only type-check the files that are staged (ignoring all untracked and unstaged files). This tool would be ideal for this, provided I can fully ignore the files provided without needing to know the error codes beforehand.

@Gelio
Copy link
Owner

Gelio commented Jun 13, 2024

Thanks for providing another possible use case for this feature.

I am not opposed to adding such option to loose-ts-check.

As for your use case, I would rethink whether such a pre-commit hook is safe to use. Imagine the following 2 files:

consts.ts:

export const port = 9090;

app.ts:

import { port } from "./consts.ts";

startServer(port);

function startServer(port: number) {
  // ... (presumably starts some server)
}

There are no typechecking errors right now.

Imagine you change consts.ts to:

export const port = '9090'; // it is a string now

You stage consts.ts, it has no typechecking errors inside of it. Thus, your pre-commit hook would pass. However, there is now an error in app.ts because it tries to call startServer with a string, whereas it expects a number for the port.

That is why IMO such a pre-commit hook is unsafe.

I would stay that limiting some operation to only staged files is safe when the checks/transformations affect just that one file. For checks in which one file can affect another one, I wouldn't rely on checking only staged files.

@olafurkarl
Copy link

olafurkarl commented Jun 13, 2024

Thanks for the feedback, I agree! Before such a hook is safe, it'd need to consider each staged file as well as any file in those files' dependency graph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants