Documentation
Languages and Frameworks/JavaScript & TypeScript

JavaScript & TypeScript Support

ThinkCode provides exceptional support for JavaScript and TypeScript development, offering specialized tools, intelligent code assistance, and performance optimization features designed specifically for these languages.

Getting Started

Setup and Configuration

ThinkCode automatically detects JavaScript and TypeScript projects. For optimal experience:

  1. Open a JavaScript/TypeScript Project:

    • Open a folder containing JavaScript/TypeScript files
    • ThinkCode detects project type and enables relevant features
  2. Configuration Files:

    • ThinkCode supports standard configuration files:
      • tsconfig.json - TypeScript configuration
      • jsconfig.json - JavaScript configuration
      • .eslintrc.* - ESLint configuration
      • .prettierrc.* - Prettier configuration
  3. Project Initialization: Use built-in templates to quickly bootstrap new projects:

    • Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
    • Type "ThinkCode: Create New Project"
    • Select JavaScript/TypeScript from template categories

IntelliSense and Code Navigation

Type Intelligence

ThinkCode provides advanced type intelligence for JavaScript and TypeScript:

  • Type Inference: Automatic type detection even in JavaScript files
  • JSDoc Support: Rich intelligence from JSDoc comments in JavaScript
  • Type Definition Files: Automatic loading of .d.ts files
  • Type Checking: Real-time type error detection

Example of type checking in action:

// ThinkCode shows errors for type mismatches
function greet(name: string): string {
  return `Hello, ${name}!`;
}
 
const result = greet(42); // Error: Argument of type 'number' is not assignable to parameter of type 'string'

Smart Navigation

Navigate your codebase efficiently:

  • Go to Definition: Jump to variable/function definitions

    • Keyboard: F12 or Ctrl+Click / Cmd+Click
    • Works across files and dependencies
  • Find All References: Locate all usages of a symbol

    • Keyboard: Shift+F12
    • Results organized by file and type
  • Peek Definition: View definitions without leaving current file

    • Keyboard: Alt+F12
    • Edit inline with the peek window
  • Symbol Navigation: Navigate by symbols

    • File symbols: Ctrl+Shift+O / Cmd+Shift+O
    • Workspace symbols: Ctrl+T / Cmd+T

Code Completion

ThinkCode's AI-powered code completion for JavaScript/TypeScript offers:

  • Context-Aware Suggestions: Completions based on surrounding code
  • Import Suggestions: Automatic import statements
  • API Usage Patterns: Complete common patterns for APIs
  • Documentation: Inline documentation with completions

Activate enhanced completions with:

// settings.json
{
  "thinkcode.javascript.completions": {
    "enhancedAi": true,
    "includePatterns": true,
    "suggestImports": true
  }
}

AI-Powered Development Features

Smart Code Generation

Generate code with natural language prompts:

  1. Function Generation:

    • Add a comment describing function purpose
    • Press Alt+I / Option+I for AI implementation

    Example:

    // Generate a function that formats a date as YYYY-MM-DD
    // Press Alt+I here and ThinkCode generates the implementation
    function formatDate(date: Date): string {
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, '0');
      const day = String(date.getDate()).padStart(2, '0');
      return `${year}-${month}-${day}`;
    }
  2. Code Transformation:

    • Select code to transform
    • Open Command Palette
    • Type "ThinkCode: Transform Code"
    • Choose transformation (e.g., "Convert to arrow function")
  3. Test Generation:

    • Select function to test
    • Right-click and select "Generate Tests"
    • ThinkCode analyzes function and generates appropriate tests

Code Refactoring

AI-assisted refactoring capabilities:

  • Smart Renaming: Intelligently rename symbols across files
  • Extract Function/Variable: Extract selections with proper parameters
  • Convert Syntax: Transform between code styles
    • CommonJS ↔ ES Modules
    • Classes ↔ Functions
    • Promise chains ↔ async/await

Customize refactoring settings:

{
  "thinkcode.javascript.refactoring": {
    "preferArrowFunctions": true,
    "preferConst": true,
    "preferTemplate": true,
    "codeStyle": "modern" // Options: "legacy", "modern", "functional"
  }
}

Documentation Assistant

Generate and maintain documentation:

  • JSDoc Generation: Auto-generate comprehensive JSDoc comments
  • README Creation: Generate project documentation
  • API Documentation: Create API reference documentation

Example of AI-assisted documentation:

// Place cursor here and use Command Palette > "Generate Documentation"
/**
 * Calculates the total price including tax and shipping
 * 
 * @param {number} basePrice - The base price of the item
 * @param {number} taxRate - The tax rate as a decimal (e.g., 0.07 for 7%)
 * @param {Object} options - Additional calculation options
 * @param {number} [options.shipping=5.99] - Shipping cost
 * @param {number} [options.discount=0] - Discount amount
 * @returns {number} The total price
 * @throws {Error} If basePrice or taxRate is negative
 * 
 * @example
 * // Returns 27.67
 * calculateTotal(19.99, 0.08, { shipping: 5.99 });
 */
function calculateTotal(basePrice, taxRate, options = {}) {
  // Implementation...
}

Project Management

Dependency Management

ThinkCode simplifies managing JavaScript/TypeScript dependencies:

  • Package Visualization: View dependency graphs
  • Version Management: Update packages with inline suggestions
  • Vulnerability Scanning: Identify and fix security issues
  • Import Optimization: Remove unused imports

Access dependency tools:

  1. Right-click on package.json
  2. Select "Manage Dependencies"

Build Configuration

Configure build systems from within ThinkCode:

  • Webpack Integration: Configuration assistance and optimization
  • Vite Support: Enhanced development for Vite projects
  • Rollup/esbuild: Configuration templates and validation

Example Webpack analyzer:

{
  "thinkcode.javascript.buildTools": {
    "webpack": {
      "analyzerEnabled": true,
      "suggestOptimizations": true
    }
  }
}

Environment Management

Manage multiple environments and runtimes:

  • Node.js Version Switching: Change Node.js versions
  • Environment Variables: Manage .env files with syntax highlighting
  • Runtime Selection: Choose between browsers, Node.js, or Deno

Frameworks Support

ThinkCode provides specialized support for popular JavaScript/TypeScript frameworks:

React

  • Component Intelligence: Smart completions for props and hooks
  • JSX Snippets: Common patterns and accessibility features
  • State Management: Visualization for React state and context
  • Performance Tools: Component render analysis

Angular

  • Template Validation: Detect errors in Angular templates
  • Component Navigation: Jump between template and component code
  • Service Assistance: Generate and integrate services
  • NgRx Support: State management tools and visualization

Vue

  • Template Syntax: Validation and intelligence in Vue templates
  • Component Management: Navigate between template, script, and style
  • Reactivity Tracking: Visualize reactive dependencies
  • Composition API: Enhanced support for composition functions

Node.js

  • API Completion: Built-in and module API suggestions
  • Express Intelligence: Route management and middleware assistance
  • Debugging: Advanced Node.js debugging capabilities
  • Performance Profiling: CPU and memory profiling integration

Advanced TypeScript Features

Type System Navigation

Navigate complex type systems effectively:

  • Type Hierarchy View: Visualize inheritance relationships
  • Type Inspector: Examine complex types with expansion UI
  • Conditional Type Resolution: Visualize conditional type paths

Access type visualization:

  1. Right-click on a type
  2. Select "Show Type Hierarchy" or "Inspect Type"

Type Refactoring

Refactor types intelligently:

  • Extract Interface/Type: Generate interfaces from usage
  • Convert Types: Transform between interfaces and types
  • Utility Type Application: Apply utility types with previews

Project References

Manage TypeScript project references:

  • Visual Project References: Navigate and manage project dependencies
  • Configuration Assistance: Validate and optimize project references
  • Build Optimization: Intelligent incremental builds

Debugging and Testing

Debugging

ThinkCode provides powerful JavaScript/TypeScript debugging:

  • Launch Configurations: Preconfigured debug setups for common scenarios
  • Breakpoint Enhancements:
    • Conditional breakpoints
    • Log points (logging without stopping)
    • Data breakpoints (break on value changes)
  • Debug Console: TypeScript-aware expression evaluation
  • Hot Swapping: Edit code during debug sessions

Example launch configuration:

// .vscode/launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "thinkcode-js",
      "request": "launch",
      "name": "Debug Current File",
      "program": "${file}",
      "smartStep": true,
      "skipFiles": ["<node_internals>/**"]
    }
  ]
}

Testing

Integrated testing for JavaScript/TypeScript:

  • Test Explorer: View and run tests with visual UI
  • Coverage Visualization: Highlight code coverage inline
  • Framework Integration: Support for Jest, Mocha, Jasmine, and Vitest
  • AI Test Analysis: Identify missing test cases

Enable test features:

{
  "thinkcode.javascript.testing": {
    "enabled": true,
    "framework": "auto", // Auto-detect or specify: "jest", "mocha", etc.
    "showCoverage": true,
    "aiAssisted": true
  }
}

Performance Optimization

Code Analysis

ThinkCode analyzes your JavaScript/TypeScript code for performance:

  • Bundle Size Analysis: Identify large dependencies
  • Runtime Performance: Detect potential bottlenecks
  • Memory Leak Detection: Find common memory leak patterns
  • Algorithmic Complexity: Suggestions for more efficient algorithms

Access performance tools:

  1. Command Palette
  2. Type "ThinkCode: Analyze Performance"

Optimization Suggestions

Receive intelligent suggestions for improving performance:

  • Code Transformations: Optimize common patterns automatically
  • Lazy Loading: Suggestions for code splitting and lazy loading
  • Rendering Optimization: Detect and fix render performance issues
  • Network Efficiency: Identify chatty network patterns

Best Practices and Code Quality

Linting and Formatting

ThinkCode integrates with popular linting and formatting tools:

  • ESLint Integration: Real-time linting with quick fixes
  • Prettier Support: Format code on save or with commands
  • Custom Rules: Define and enforce team coding standards
  • AI-Enhanced Linting: Detect logical issues beyond syntax errors

Configure linting:

{
  "thinkcode.javascript.linting": {
    "eslint": {
      "enabled": true,
      "autoFixOnSave": true,
      "validateOnType": true
    },
    "aiLinting": {
      "enabled": true,
      "strictness": "medium" // Options: "relaxed", "medium", "strict"
    }
  }
}

Code Quality Metrics

Monitor and improve code quality:

  • Complexity Analysis: Measure and visualize code complexity
  • Technical Debt: Track and manage technical debt
  • Code Smells: Identify and refactor problematic patterns
  • Duplications: Find and consolidate duplicate code

Security Analysis

Detect and fix security vulnerabilities:

  • Static Analysis: Find common security issues
  • Dependency Scanning: Check for vulnerable packages
  • Input Validation: Verify proper input handling
  • Authentication Patterns: Validate secure authentication implementations

Customization

Extension Points

Extend ThinkCode's JavaScript/TypeScript support:

  • Custom Type Providers: Add specialized type intelligence
  • Code Action Providers: Create custom code refactorings
  • Analyzers: Develop custom code analyzers
  • Formatters: Implement specialized formatting rules

Configuration Options

Comprehensive configuration for JavaScript/TypeScript:

{
  "thinkcode.javascript": {
    "format": {
      "semicolons": "insert", // Options: "insert", "remove"
      "quotes": "single", // Options: "single", "double"
      "trailingCommas": "all" // Options: "none", "es5", "all"
    },
    "suggestions": {
      "completeFunctionCalls": true,
      "classMembers": true,
      "autoImports": true,
      "paths": true
    },
    "validation": {
      "strictNullChecks": true,
      "noImplicitAny": true,
      "strictFunctionTypes": true
    }
  }
}

Resources and Learning

Learning Paths

ThinkCode offers integrated learning experiences:

  • Interactive Tutorials: Learn JavaScript/TypeScript concepts
  • Code Challenges: Practice with hands-on exercises
  • Sample Projects: Explore and learn from example projects
  • Best Practice Guides: Context-sensitive coding guidelines

Access learning resources:

  1. Command Palette
  2. Type "ThinkCode: Open Learning Hub"
  3. Select JavaScript/TypeScript category

Community Resources

Connect with the JavaScript/TypeScript community:

  • Snippet Sharing: Share and discover useful code snippets
  • Extension Recommendations: Find helpful extensions
  • Forums Integration: Search solutions from Stack Overflow
  • GitHub Discussions: Access related GitHub discussions

Further Information