Skip to content

⬅️ Back to Table of Contents

📄 spec.ts

📊 Analysis Summary

Metric Count
📦 Imports 5
📐 Interfaces 6
📑 Type Aliases 3

📚 Table of Contents

🛠️ File Location:

📂 packages/ast-spec/src/special/VariableDeclarator/spec.ts

📦 Imports

Name Source
AST_NODE_TYPES ../../ast-node-types
BaseNode ../../base/BaseNode
Identifier ../../expression/Identifier/spec
BindingName ../../unions/BindingName
Expression ../../unions/Expression

Interfaces

VariableDeclaratorBase

Interface Code
interface VariableDeclaratorBase extends BaseNode {
  type: AST_NODE_TYPES.VariableDeclarator;
  /**
   * Whether there's definite assignment assertion (`let x!: number`).
   * If `true`, then: `id` must be an identifier with a type annotation,
   * `init` must be `null`, and the declarator must be a `var`/`let` declarator.
   */
  definite: boolean;
  /**
   * The name(s) of the variable(s).
   */
  id: BindingName;
  /**
   * The initializer expression of the variable. Must be present for `const` unless
   * in a `declare const`.
   */
  init: Expression | null;
}

Properties

Name Type Optional Description
type AST_NODE_TYPES.VariableDeclarator
definite boolean
id BindingName
init Expression | null

VariableDeclaratorNoInit

Interface Code
export interface VariableDeclaratorNoInit extends VariableDeclaratorBase {
  definite: false;
  init: null;
}

Properties

Name Type Optional Description
definite false
init null

VariableDeclaratorMaybeInit

Interface Code
export interface VariableDeclaratorMaybeInit extends VariableDeclaratorBase {
  definite: false;
}

Properties

Name Type Optional Description
definite false

VariableDeclaratorDefiniteAssignment

Interface Code
export interface VariableDeclaratorDefiniteAssignment
  extends VariableDeclaratorBase {
  definite: true;
  /**
   * The name of the variable. Must have a type annotation.
   */
  id: Identifier;
  init: null;
}

Properties

Name Type Optional Description
definite true
id Identifier
init null

UsingInNormalContextDeclarator

Interface Code
export interface UsingInNormalContextDeclarator extends VariableDeclaratorBase {
  definite: false;
  id: Identifier;
  init: Expression;
}

Properties

Name Type Optional Description
definite false
id Identifier
init Expression

UsingInForOfDeclarator

Interface Code
export interface UsingInForOfDeclarator extends VariableDeclaratorBase {
  definite: false;
  id: Identifier;
  init: null;
}

Properties

Name Type Optional Description
definite false
id Identifier
init null

Type Aliases

LetOrConstOrVarDeclarator

type LetOrConstOrVarDeclarator = | VariableDeclaratorDefiniteAssignment
  | VariableDeclaratorMaybeInit
  | VariableDeclaratorNoInit;

UsingDeclarator

type UsingDeclarator = | UsingInForOfDeclarator
  | UsingInNormalContextDeclarator;

VariableDeclarator

type VariableDeclarator = LetOrConstOrVarDeclarator | UsingDeclarator;