Skip to content

⬅️ Back to Table of Contents

📄 warnAboutTSVersion

📊 Analysis Summary

Metric Count
🔧 Functions 2
📦 Imports 3
📊 Variables & Constants 4

📚 Table of Contents

🛠️ File Location:

📂 packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts

📦 Imports

Name Source
semver semver
ParseSettings ./index
TYPESCRIPT_ESTREE_VERSION ../version

Variables & Constants

Name Type Kind Value Exported
SUPPORTED_TYPESCRIPT_VERSIONS ">=4.8.4 <6.1.0" const '>=4.8.4 <6.1.0'
SUPPORTED_PRERELEASE_RANGES string[] const []
ACTIVE_TYPESCRIPT_VERSION any const ts.version
warnedAboutTSVersion boolean let/var false

Functions

handleUnsupportedTSVersion(parseSettings: ParseSettings, behavior: 'error' | 'ignore' | 'warn', passedLoggerFn: boolean): void

Parameters:

  • parseSettings ParseSettings
  • behavior 'error' | 'ignore' | 'warn'
  • passedLoggerFn boolean

Returns: void

Calls:

  • buildUnsupportedTSVersionMessage
  • parseSettings.log

Internal Comments:

// See https://github.com/typescript-eslint/typescript-eslint/issues/7896
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition

Code
export function handleUnsupportedTSVersion(
  parseSettings: ParseSettings,
  behavior: 'error' | 'ignore' | 'warn',
  passedLoggerFn: boolean,
): void {
  if (isRunningSupportedTypeScriptVersion || behavior === 'ignore') {
    return;
  }

  if (behavior === 'error') {
    throw new Error(buildUnsupportedTSVersionMessage('error'));
  }

  if (warnedAboutTSVersion) {
    return;
  }

  if (
    passedLoggerFn ||
    // See https://github.com/typescript-eslint/typescript-eslint/issues/7896
    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
    (typeof process === 'undefined' ? false : process.stdout?.isTTY)
  ) {
    parseSettings.log(buildUnsupportedTSVersionMessage('warn'));
  }

  warnedAboutTSVersion = true;
}

buildUnsupportedTSVersionMessage(severity: 'error' | 'warn'): string

Parameters:

  • severity 'error' | 'warn'

Returns: string

Calls:

  • [ border, '\n',${label}: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree., '\n', @typescript-eslint/typescript-estree version: ${TYPESCRIPT_ESTREE_VERSION}, Supported TypeScript versions: ${SUPPORTED_TYPESCRIPT_VERSIONS},* Your TypeScript version: ${ACTIVE_TYPESCRIPT_VERSION}, '\n', 'Please only submit bug reports when using the officially supported version.', '\n', border, ].join
Code
function buildUnsupportedTSVersionMessage(severity: 'error' | 'warn'): string {
  const label = severity === 'error' ? 'ERROR' : 'WARNING';
  const border = '=============';
  return [
    border,
    '\n',
    `${label}: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.`,
    '\n',
    `* @typescript-eslint/typescript-estree version: ${TYPESCRIPT_ESTREE_VERSION}`,
    `* Supported TypeScript versions: ${SUPPORTED_TYPESCRIPT_VERSIONS}`,
    `* Your TypeScript version: ${ACTIVE_TYPESCRIPT_VERSION}`,
    '\n',
    'Please only submit bug reports when using the officially supported version.',
    '\n',
    border,
  ].join('\n');
}

Generated by Syntax Scribe