unicorn/prefer-math-min-max is incorrectly reporting variables of bigint type.
Its autofix generates invalid code.
{
"private": true,
"type": "module",
"packageManager": "[email protected]+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c",
"dependencies": {
"typescript": "~5.7.2",
"xo": "^0.60.0"
}
}
{
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"lib": [
"DOM",
"ES2023"
],
"module": "ES2022",
"moduleResolution": "Bundler",
"noEmitOnError": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"strict": true,
"target": "ES2023"
},
"include": [
"main.ts"
],
"exclude": [
"**/node_modules"
]
}
export function f(a: bigint, b = 0n) {
return a > b ? a : b;
}
./node_modules/.bin/xo
main.ts:2:9
β 2:9 Prefer Math.max() to simplify ternary expressions. unicorn/prefer-math-min-max
1 error
export function f(a: bigint, b = 0n) {
return Math.max(a, b);
}
main.ts:2:18 - error TS2345: Argument of type 'bigint' is not assignable to parameter of type 'number'.
2 return Math.max(a, b);
~
Found 1 error in main.ts:2
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too