Skip to content

⬅️ Back to Table of Contents

📄 getValueOfLiteralType

📊 Analysis Summary

Metric Count
🔧 Functions 3

📚 Table of Contents

🛠️ File Location:

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

Functions

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

Parameters:

  • type ts.LiteralType

Returns: bigint | number | string

Calls:

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

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

Parameters:

  • value number | string | ts.PseudoBigInt

Returns: value is ts.PseudoBigInt

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

pseudoBigIntToBigInt(value: ts.PseudoBigInt): bigint

Parameters:

  • value ts.PseudoBigInt

Returns: bigint

Calls:

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

Generated by Syntax Scribe