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

🐛 Bug: bigint is not added to types when adding missing types #1482

Closed
3 tasks done
rubiesonthesky opened this issue Mar 29, 2024 · 3 comments · Fixed by #1513
Closed
3 tasks done

🐛 Bug: bigint is not added to types when adding missing types #1482

rubiesonthesky opened this issue Mar 29, 2024 · 3 comments · Fixed by #1513
Assignees
Labels
area: fixers Around how TypeStat fixes code. status: accepting prs Please, send a pull request to resolve this! 🙏 type: bug Something isn't working :( 🐛

Comments

@rubiesonthesky
Copy link
Collaborator

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

const returnsBigInt = (): string => {
  return BigInt("123");
};

should be mutated to

const returnsBigInt = (): string | bigint => {
  return BigInt("123");
};

Actual

Instead it will stay as:

const returnsBigInt = (): string => {
  return BigInt("123");
};

Additional Info

Curiously, this code is fixed correctly

const returnsPromiseBigInt = (): string => {
  return Promise.resolve(BigInt("123"));
};

to

const returnsPromiseBigInt = (): string | Promise<bigint> => {
  return Promise.resolve(BigInt("123"));
};

I have already found a fix for this. By adding BigIntLiteral and BigInt to nonStrictTypeFlagAliases, we will get the correct behavior.

@rubiesonthesky rubiesonthesky added the type: bug Something isn't working :( 🐛 label Mar 29, 2024
@rubiesonthesky rubiesonthesky self-assigned this Mar 29, 2024
@rubiesonthesky rubiesonthesky added the status: accepting prs Please, send a pull request to resolve this! 🙏 label Mar 29, 2024
@rubiesonthesky
Copy link
Collaborator Author

I'm having hard time understanding why the test passes with the fix when using vitest, but not with the current test system.

The main difference with these test systems is, that with current system, the test are run with compiled javascript files. And with vitest, the test are run with typescript source files and vitest is taking care of compilation.

@rubiesonthesky rubiesonthesky added the area: fixers Around how TypeStat fixes code. label Mar 30, 2024
Repository owner deleted a comment from allcontributors bot Mar 30, 2024
@JoshuaKGoldberg
Copy link
Owner

I wonder if that's related to #1479? Now that main is updated, maybe it'll all be resolved? 🤞

@rubiesonthesky
Copy link
Collaborator Author

More investigation with my fix:

This does not work

const returnsBigInt = (): number => {
  return BigInt("123");
};

But this works

const returnsBigInt2 = (): number => {
  return 123n;
};

->

const returnsBigInt2 = (): number | bigint => {
  return 123n;
};

So somewhere there is issue where BigInt is not changes to bigint. I also tried to play with target as BigInt is only in target ES2020 ->

JoshuaKGoldberg pushed a commit that referenced this issue Apr 9, 2024
<!-- 👋 Hi, thanks for sending a PR to TypeStat! 💖.
Please fill out all fields below and make sure each item is true and [x]
checked.
Otherwise we may not be able to review your PR. -->

## PR Checklist

- [x] Addresses an existing open issue: fixes #1482
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/TypeStat/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/TypeStat/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

<!-- Description of what is changed and how the code change does that.
-->

Fixes missing bigint types (finally) 🎉
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: fixers Around how TypeStat fixes code. status: accepting prs Please, send a pull request to resolve this! 🙏 type: bug Something isn't working :( 🐛
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants