Is it possible to declare a typescript function which works on both numbers and bigints?
问题 In plain untyped Javascript, it's not so hard to write a function which can operate on either numbers or bigints, depending on the arguments which are passed in: const sumOfSquares = (a,b) => a*a + b*b; sumOfSquares(3, 4); // returns 25 sumOfSquares(3n, 4n); // returns 25n sumOfSquares(3n, 4); // throws a TypeError It seems like there ought to be a way to declare this function in typescript so that the compiler will enforce that the arguments will work together. I tried const sumOfSquares =