Skip to content

⬅️ Back to Table of Contents

📄 getImportClausePhaseModifier

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 1
📊 Variables & Constants 1
📑 Type Aliases 1

📚 Table of Contents

🛠️ File Location:

📂 packages/typescript-estree/src/getImportClausePhaseModifier.ts

📦 Imports

Name Source
typescriptVersionIsAtLeast ./version-check

Variables & Constants

Name Type Kind Value Exported
isAtLeast59 boolean const typescriptVersionIsAtLeast['5.9']

Functions

getImportClausePhaseModifier(node: ts.ImportClause | null | undefined): ImportClausePhaseModifier

Parameters:

  • node ts.ImportClause | null | undefined

Returns: ImportClausePhaseModifier

Internal Comments:

// eslint-disable-next-line @typescript-eslint/no-deprecated -- guarded by TS version check.
// eslint-disable-next-line @typescript-eslint/no-deprecated -- guarded by TS version check

Code
export function getImportClausePhaseModifier(
  node: ts.ImportClause | null | undefined,
): ImportClausePhaseModifier {
  if (!node) {
    return null;
  }

  if (isAtLeast59) {
    // eslint-disable-next-line @typescript-eslint/no-deprecated -- guarded by TS version check.
    return node.phaseModifier === ts.SyntaxKind.TypeKeyword
      ? 'type'
      : // eslint-disable-next-line @typescript-eslint/no-deprecated -- guarded by TS version check
        node.phaseModifier === ts.SyntaxKind.DeferKeyword
        ? 'defer'
        : null;
  }

  // eslint-disable-next-line @typescript-eslint/no-deprecated -- guarded by TS version check
  return node.isTypeOnly ? 'type' : null;
}

Type Aliases

ImportClausePhaseModifier

type ImportClausePhaseModifier = 'defer' | 'type' | null;

Generated by Syntax Scribe