๐ Bug: bigint is not added to types when adding missing types
rubiesonthesky opened this issue ยท 3 comments
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.
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.
I wonder if that's related to #1479? Now that main
is updated, maybe it'll all be resolved? ๐ค
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 ->