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, andslice) and fundamental language keywords (likeclass,const,export,import,return,try, andyield). - Operator Mapping: Leverages the
Operatorsconfiguration helper to bind standard algebraic, assignment, bitwise, logic, and lambda operators to JavaScript syntaxes (such as mappingMATH_EQUALto===andLAMBDAto=>). - 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_CASEas 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 (likefrom importresulting infrom ""). - Deprecations: Provides fallback error reporting or updates for outdated syntax rules (like redirecting raw array
map/filtercommands 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
logorprintresolve toconsole.log. - Math commands such as
floor,round,min, andmaxtargetMathnamespace equivalents. - Object utilities like
keysorentriestranslate directly toObject.keysorObject.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:
- Standard programming commands (like assignment, math operations, and object accessor usage) map directly to JavaScript syntax using the operators registered in Python.
- Formatting configurations inside the
.talonfile intercept newly declared functions or variables, feeding them through the CamelCase formatter defined in the Python action class before outputting them to the editor. - The common functions defined in the
.talon-listfile provide global voice shortcuts that seamlessly integrate alongside the custom keywords and actions.