-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Allow minimal type checking of JavaScript files #28448
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
Comments
Can you weigh in on options like:
|
Thanks for the quick response, @DanielRosenwasser! I appreciate your suggestions, but I don't think either of those options satisfy our use case. Let me give an example. We have a component called In order to replicate this feature with Either way it would be a lot of extra work, and not particularly meaningful work either. The errors that I would be ignoring (such as |
I'm also working on converting a large project (> 1000 files) to TypeScript. We're using Currently, the TS compiler gives us > 12 000 errors in our codebase and most of these aren't really that interesting ( If we could use a Currently, some devs opt out of checking JavaScript files because it's too noisy and doesn't add that much value. This is somewhat related to another issue I reported (#29810). |
Checking Implicit any when checkJs doesn't really make sense, because we can't add types in JavaScript files anyway. |
@hzhang1902 Yes you can, with JSDoc type annotations |
Could this be achieved by having a second tsconfig that only targets JS files and overrides the |
I am generated prisma client (js files) in my workspace, and I have a bunch of error on js files when I set allowJs=true with checkJs=false. Is there a way to not check at all js ? |
I'm in the process of introducing TypeScript support into an enormous, 6-year old web application with a lot of JavaScript files. In order to get the most advantages out of TypeScript while we slowly migrate over (which will likely happen slowly), I'd like the following to be true:
.ts
and.tsx
) are type checked withstrict: true
, so that we get as much useful feedback about TS code as possible.strict: false
to minimize the number of errors they output.Primary Suggestion
It would be fantastic if typescript had a
"minimalCheckJs"
config option that, when set to true, would only check JS files for errors on imported typed code. For example, setting"minimalCheckJs": true, "strict": true
intsconfig.json
would have this effect:This feature would allow me to convert a file from JS to TS, add types to the file, and immediately be assured that the exported code is being used correctly throughout my entire code base (including JS files). Currently, I can set
"checkJs": true
, but then I will see thousands of other kinds of errors that TypeScript finds in the JS files, such ascannot find module
errors.Alternative Suggestion
If the above feature is difficult to implement, a less ideal but also helpful feature would be to allow setting
"strict": false
for JS files and"strict": true
for TS files. Some way to combine the following:The text was updated successfully, but these errors were encountered: