Skip to content

⬅️ Back to Table of Contents

📄 getValueOfLiteralType.ts

📊 Analysis Summary

Metric Count
🔧 Functions 3

📚 Table of Contents

🛠️ File Location:

📂 packages/eslint-plugin/src/util/getValueOfLiteralType.ts

Functions

valueIsPseudoBigInt(value: number | string | ts.PseudoBigInt): value is ts.PseudoBigInt

Code
(
  value: number | string | ts.PseudoBigInt,
): value is ts.PseudoBigInt => {
  return typeof value === 'object';
}
  • Parameters:
  • value: number | string | ts.PseudoBigInt
  • Return Type: value is ts.PseudoBigInt

pseudoBigIntToBigInt(value: ts.PseudoBigInt): bigint

Code
(value: ts.PseudoBigInt): bigint => {
  return BigInt((value.negative ? '-' : '') + value.base10Value);
}
  • Parameters:
  • value: ts.PseudoBigInt
  • Return Type: bigint
  • Calls:
  • BigInt

getValueOfLiteralType(type: ts.LiteralType): bigint | number | string

Code
(
  type: ts.LiteralType,
): bigint | number | string => {
  if (valueIsPseudoBigInt(type.value)) {
    return pseudoBigIntToBigInt(type.value);
  }
  return type.value;
}
  • Parameters:
  • type: ts.LiteralType
  • Return Type: bigint | number | string
  • Calls:
  • valueIsPseudoBigInt
  • pseudoBigIntToBigInt