Skip to content

Conversation

@Ollec
Copy link
Contributor

@Ollec Ollec commented Oct 27, 2025

Hello, @terryyin, I don't know Typescript or JavaScript, but I let Claude take a look at this one, so please give it a closer eye and let me know what you think.


Fixes missing method detection and false positives in JavaScript/TypeScript parser that were reported in issue #415.

Issues Fixed

Missing static async methods: static async simulateApiCall() was not being detected by the parser
False positive constructor calls: new Date() was incorrectly reported as a function definition
False positive method calls: Method calls like Date.toISOString() and this.generateRandomId() were incorrectly reported as function definitions

Changes Made

Parser Improvements (lizard_languages/typescript.py)
Added tracking for static and async keyword modifiers to properly handle static async method combinations
Added _prev_token tracking to detect new keyword and . operator context
Enhanced method call detection to prevent false positives when ( is preceded by . or new
Improved token preservation logic to maintain context across multiple tokens

Test Coverage

Added tests to both testJavaScript.py and testTypeScript.py:
test_interactive_widget_from_github_issue_415() - Tests the full InteractiveWidget class example from the bug report
test_no_false_positive_method_calls() - Verifies method calls and constructor calls are not detected as functions
Documented known limitation: methods appearing after complex async methods with nested callbacks may not be detected

Test Results

✅ 54 JavaScript/TypeScript tests passing (4 skipped - documented edge cases)
✅ 1012 total lizard tests passing (6 skipped)
✅ No regressions
✅ PEP8 compliant

Verification

All critical methods from the InteractiveWidget example in issue #415 are now correctly detected:
constructor, init, render, updateUI, handleClick
startTimer, stopTimer, formatDate, generateRandomId
simulateApiCall (the main missing method from the bug report)
No false positives detected for:
Constructor calls: new Date()
Method calls: Date.toISOString(), this.generateRandomId()

Known Limitations

Methods appearing after a static async method containing complex nested callbacks (Promise + setTimeout) with method calls inside object literals may not be detected. This affects 2 methods (processItems, filterUnique) in the full InteractiveWidget example, but all methods specifically mentioned in the bug report are now working correctly. Fixes #415

@terryyin
Copy link
Owner

thanks for the fix. I will try if there's a solution for the "known limitations"

@terryyin terryyin merged commit 67b799b into terryyin:master Oct 28, 2025
4 of 5 checks 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.

Issue with typescript & javascript

2 participants