Skip to content

javascript

This directory provides comprehensive support for voice-coding in JavaScript and TypeScript, including React variations (javascriptreact and typescriptreact). It contains configuration files, list mappings, and Python extension scripts that work in unison to activate standard programming tags, specify formatting rules, expose core language keywords, and generate syntactical structures like functions and operators.

Component Overview

The language features are implemented across three primary files:

javascript.py

This script acts as the backend for JavaScript/TypeScript syntax. It establishes the context matches for language scopes and implements target-specific logic:

  • List Definitions: Populates lists for common object methods (like catch, filter, map, and slice) and fundamental language keywords (like class, const, export, import, return, try, and yield).
  • Operator Mapping: Leverages the Operators configuration helper to bind standard algebraic, assignment, bitwise, logic, and lambda operators to JavaScript syntaxes (such as mapping MATH_EQUAL to === and LAMBDA to =>).
  • Actions Overrides: Defines custom insertion behavior for constants (e.g., true, false, null), null checks (=== null), and class/module scopes (this).
  • Function Declarations: Programmatically structures and inserts functions. Whether defining a private, public, or default function, it automatically formats the name according to the CamelCase settings and inserts parameter parenthesis.

javascript.talon

This file binds voice commands to key constructs and organizes active syntax definitions. It manages:

  • Tag Activation: Plugs into Talon's generic programming framework by activating standard interfaces such as user.code_imperative, user.code_object_oriented, data/null formats, and comment block types.
  • Formatting Constraints: Enforces PRIVATE_CAMEL_CASE as the standard formatter for variables and functions.
  • State Statements: Exposes voice commands for language features like variable declarations (const, let, var), exports, spread syntax (...), asynchronous keywords (async, await), and structural patterns (like from import resulting in from "").
  • Deprecations: Provides fallback error reporting or updates for outdated syntax rules (like redirecting raw array map / filter commands to their fluent "dot" equivalent).

code_common_function.talon-list

A specialized lookup table matching intuitive spoken words to runtime-defined global functions and standard library helpers.

  • Spoken commands such as log or print resolve to console.log.
  • Math commands such as floor, round, min, and max target Math namespace equivalents.
  • Object utilities like keys or entries translate directly to Object.keys or Object.entries.

How the Files Work Together

When a user edits a file containing a JavaScript or TypeScript extension, the matchers configured in both javascript.py and javascript.talon detect the language.

Once active:

  1. Standard programming commands (like assignment, math operations, and object accessor usage) map directly to JavaScript syntax using the operators registered in Python.
  2. Formatting configurations inside the .talon file intercept newly declared functions or variables, feeding them through the CamelCase formatter defined in the Python action class before outputting them to the editor.
  3. The common functions defined in the .talon-list file provide global voice shortcuts that seamlessly integrate alongside the custom keywords and actions.