Skip to content

Conversation

@prosdev
Copy link
Collaborator

@prosdev prosdev commented Dec 2, 2025

Summary

Implements arrow function and function expression extraction for the TypeScript scanner, addressing issue #119.

Changes

New Features

  • Variable extraction: Extracts arrow functions and function expressions assigned to const/let variables
  • Hook detection: Automatically detects React hooks by use* naming convention
  • Async detection: Flags async arrow functions via isAsync metadata
  • Full metadata: Extracts callees, JSDoc, imports, and signatures from function bodies

API Additions

  • Added 'variable' to DocumentType union type
  • Added optional metadata fields:
    • isArrowFunction: boolean - true for arrow functions (vs function expressions)
    • isHook: boolean - true if name matches /^use[A-Z]/
    • isAsync: boolean - true for async functions

Examples

Now extracts:

export const useAuth = () => { ... }           // Hook
export const fetchData = async (url) => { ... } // Async function
const validateEmail = (email: string) => ...   // Utility function
const legacy = function(a, b) { return a + b } // Function expression

Still skips (as intended):

const API_URL = '/api'           // Primitive constant
const config = { timeout: 5000 } // Object literal

Testing

  • Added 11 new tests covering all extraction patterns
  • All 1483 tests pass
  • Lint and typecheck pass

Closes

Closes #119

- Add 'variable' to DocumentType for variable-assigned functions
- Add metadata: isArrowFunction, isHook, isAsync
- Extract arrow functions assigned to const/let variables
- Extract function expressions assigned to variables
- Detect React hooks by 'use*' naming convention
- Extract callees and JSDoc from arrow function bodies
- Add 11 tests covering extraction patterns

Closes #119
…ializers

- Extract exported const with object literal initializers (config objects)
- Extract exported const with array literal initializers (static lists)
- Extract exported const with call expression initializers (factories)
- Add metadata: isConstant, constantKind ('object' | 'array' | 'value')
- Skip non-exported constants and primitive exports (low semantic value)
- Add 6 tests for exported constant extraction patterns

This completes Phase 2 of #119.
Changeset:
- Add changeset for minor version bump (→ 0.5.0)
- Bumps @lytics/dev-agent-core and @lytics/dev-agent

Scanner docs:
- Update README with new DocumentType 'variable' and metadata fields
- Document isArrowFunction, isHook, isAsync, isConstant, constantKind

Website docs:
- Add 'New in v0.5.0' section to tools index
- Update dev_search with v0.5 markers for new extraction types
- Update quickstart with expanded extraction list
- Add /updates page with friendly release notes for all versions
- Cover v0.5.0, v0.4.4, v0.4.0, v0.3.0, and v0.1.0
- Update home page callout to link to Updates instead of GitHub
- Write in accessible language for developers and product managers
@prosdev prosdev merged commit 4bc1497 into main Dec 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve TypeScript scanner symbol extraction for modern JavaScript patterns

1 participant