Skip to content

Bug: [no-unsafe-call] process.exit(1) is an "error" type typed value #9625

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
4 tasks done
CreativeTechGuy opened this issue Jul 23, 2024 · 12 comments
Closed
4 tasks done
Labels
bug Something isn't working fix: user error issue was fixed by correcting the configuration / correcting the code locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@CreativeTechGuy
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.5.3&fileType=.tsx&code=JYWwDg9gTgLgBAbzgUwB7HgXzgMyhEOAIgDsIATZALjHwGNkBnRogbgFgAoLtDACgCMASi5daEBswB0vGIKFA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tieQEMAZolpk%2B8eOiiJo0DtEjgwAXxBKgA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

process.exit(1)


### ESLint Config

```javascript
module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/no-unsafe-call": "error"
  },
};

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

I expected process.exit(1) to not be an error.

Actual Result

There was an error when calling process.exit(1)

Additional Info

I believe this error was introduced in #9304

@CreativeTechGuy CreativeTechGuy added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jul 23, 2024
@Josh-Cena
Copy link
Member

Hmmm, fun. Are never-returning functions treated as error-typed?

@kirkwaiblinger
Copy link
Member

kirkwaiblinger commented Jul 23, 2024

Hi @CreativeTechGuy!

Does this repro for you locally or just in the playground? We've had some trouble with types in the playground lately, for example see #9594 and #8696

I believe this error was introduced in #9304

As also discussed in #9591, #9304 made no changes to whether or not the rule reports - it just changes whether the error messages say "Unsafe call of an error-typed value", instead of "Unsafe call of an any-typed value"

@CreativeTechGuy
Copy link
Author

Yes this repos locally which is how I found it when updating dependencies. So it's not just the playground @kirkwaiblinger

@kirkwaiblinger
Copy link
Member

@Josh-Cena Looks like no; this doesn't flag....

function neverTypedFunction(): never {
  throw new Error();
}

neverTypedFunction(); 

@kirkwaiblinger
Copy link
Member

@CreativeTechGuy
Gotcha, thanks for the info! My guess is that it has something funky to do with how the types are configured in the tsconfig, but some investigation will be needed it seems.

@CreativeTechGuy
Copy link
Author

I don't know the exact version this was introduced. But I can confirm that 7.14.1 was working. So something between 7.15.0-7.16.1 changed.

@kirkwaiblinger
Copy link
Member

kirkwaiblinger commented Jul 23, 2024

Just dropping one further breadcrumb for investigation, other functions on process that TS is ok with also run into this report, e.g.

process.getActiveResourcesInfo()

as well as other imported node types

import { relative } from "node:path";
relative("foo", "bar");

@JoshuaKGoldberg
Copy link
Member

Could someone post a standalone reproduction that isn't the playground please? We'll want to investigate this locally.

@bradzacher
Copy link
Member

This is likely a local setup issue yeah. Need a repro to investigate further.

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party unable to repro issues that a maintainer was not able to reproduce and removed triage Waiting for team members to take a look labels Jul 23, 2024
@CreativeTechGuy
Copy link
Author

I'll work on a repro early next week. Thank you for looking into this!

@CreativeTechGuy
Copy link
Author

It looks like it was a configuration issue. I had a global type augmentation for process so I could set the type of process.env in browser/bundler environments, and that was getting applied more broadly than I intended.

So I concede that it was user error and can be fixed. The error message was very confusing and for some reason didn't show up until I updated dependencies. Although I'm having a hard time finding a minimal reproduction.

Could the message "Unsafe call of an `error` type typed value" be renamed to something like "Unsafe call of an untyped value" or something like that? Something to indicate that it's an error because TS ESLint doesn't see it's type even though your editor/typescript does. That'd be helpful and point people in the direction of it being a configuration error with typescript configured differently than eslint.

@kirkwaiblinger
Copy link
Member

@CreativeTechGuy

Thanks for following up!

Could the message be renamed?

Let's use #9591 for that discussion.

Cheers 🙂

@kirkwaiblinger kirkwaiblinger closed this as not planned Won't fix, can't repro, duplicate, stale Jul 30, 2024
@kirkwaiblinger kirkwaiblinger added fix: user error issue was fixed by correcting the configuration / correcting the code and removed awaiting response Issues waiting for a reply from the OP or another party unable to repro issues that a maintainer was not able to reproduce labels Jul 30, 2024
@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Aug 7, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working fix: user error issue was fixed by correcting the configuration / correcting the code locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

5 participants