Skip to content

Commit c9e75f8

Browse files
committed
fix
1 parent f4482d8 commit c9e75f8

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

codeflash/discovery/functions_to_optimize.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -379,25 +379,20 @@ def get_functions_to_optimize(
379379

380380
is_exported, export_name = _is_js_ts_function_exported(file, name_to_check)
381381
if not is_exported:
382-
if is_lsp:
383-
return functions, 0, None
384382
if found_function.parents:
385-
exit_with_message(
383+
logger.debug(
386384
f"Class '{name_to_check}' containing method '{found_function.function_name}' "
387-
f"is not exported from {file}.\n"
385+
f"is not exported from {file}. "
388386
f"In JavaScript/TypeScript, only exported classes/functions can be optimized "
389-
f"because tests need to import them.\n"
390-
f"To fix: Add 'export' keyword to the class declaration, e.g.:\n"
391-
f" export class {name_to_check} {{ ... }}"
387+
f"because tests need to import them."
392388
)
393389
else:
394-
exit_with_message(
395-
f"Function '{found_function.function_name}' is not exported from {file}.\n"
390+
logger.debug(
391+
f"Function '{found_function.function_name}' is not exported from {file}. "
396392
f"In JavaScript/TypeScript, only exported functions can be optimized because "
397-
f"tests need to import them.\n"
398-
f"To fix: Add 'export' keyword to the function declaration, e.g.:\n"
399-
f" export const {found_function.function_name} = ..."
393+
f"tests need to import them."
400394
)
395+
return {}, 0, None
401396

402397
functions[file] = [found_function]
403398
else:

tests/test_javascript_function_discovery.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,11 @@ def test_get_specific_function(self, tmp_path):
346346
"""Test getting a specific function by name."""
347347
js_file = tmp_path / "math_utils.js"
348348
js_file.write_text("""
349-
function add(a, b) {
349+
export function add(a, b) {
350350
return a + b;
351351
}
352352
353-
function subtract(a, b) {
353+
export function subtract(a, b) {
354354
return a - b;
355355
}
356356
""")
@@ -378,7 +378,7 @@ def test_get_class_method(self, tmp_path):
378378
"""Test getting a specific class method."""
379379
js_file = tmp_path / "calculator.js"
380380
js_file.write_text("""
381-
class Calculator {
381+
export class Calculator {
382382
add(a, b) {
383383
return a + b;
384384
}
@@ -388,7 +388,7 @@ class Calculator {
388388
}
389389
}
390390
391-
function standaloneFunc() {
391+
export function standaloneFunc() {
392392
return 42;
393393
}
394394
""")

0 commit comments

Comments
 (0)