Skip to content

Commit

Permalink
fix: add BigInt to type aliases (#1513)
Browse files Browse the repository at this point in the history
<!-- 👋 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) 🎉
  • Loading branch information
rubiesonthesky authored Apr 9, 2024
1 parent 0869051 commit 48efbfb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mutations/aliasing/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { FileMutationsRequest } from "../../shared/fileMutator.js";
* Type flags and aliases to check when --strictNullChecks is not enabled.
*/
const nonStrictTypeFlagAliases = new Map([
[ts.TypeFlags.BigInt, "bigint"],
[ts.TypeFlags.BigIntLiteral, "bigint"],
[ts.TypeFlags.Boolean, "boolean"],
[ts.TypeFlags.BooleanLiteral, "boolean"],
[ts.TypeFlags.Number, "number"],
Expand Down
12 changes: 12 additions & 0 deletions test/cases/fixes/incompleteTypes/returnTypes/expected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,16 @@
async function returnPromise(): Promise<string> {
return Promise.resolve("");
}

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

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

const returnsNumberAndBigint = (): bigint | number => {
return 123;
};
})();
12 changes: 12 additions & 0 deletions test/cases/fixes/incompleteTypes/returnTypes/original.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,16 @@
async function returnPromise(): Promise<string> {
return Promise.resolve("");
}

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

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

const returnsNumberAndBigint = (): bigint => {
return 123;
};
})();

0 comments on commit 48efbfb

Please sign in to comment.