Skip to content

Commit aa4da14

Browse files
committed
test(ts): cover inferred stdlib constructor receivers
Signed-off-by: mikemikimike <13286568797@163.com>
1 parent 2a2be4a commit aa4da14

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎tests/repro/repro_lsp_ts.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,14 @@ static const RFile kTsInferredImportedMethod[] = {
314314
"}\n"},
315315
};
316316

317+
/* A standard-library class constructed through an inferred local variable must
318+
* retain the bare stdlib QN so subsequent member dispatch finds Map.get. */
319+
static const char kTsInferredStdlibMethod[] =
320+
"function lookup(id: string): string {\n"
321+
" const m = new Map<string, string>();\n"
322+
" return m.get(id);\n"
323+
"}\n";
324+
317325
/* lsp_ts_jsx — <Comp/> JSX element whose tag is a module-local component
318326
* function (ts_lsp.c:2643-2647). TSX only (jsx_mode); the tag's first letter is
319327
* uppercase so it is NOT treated as an intrinsic HTML element; it resolves via
@@ -395,6 +403,11 @@ TEST(repro_lsp_ts_inferred_import_receiver) {
395403
"lsp_ts_method");
396404
}
397405

406+
TEST(repro_lsp_ts_inferred_stdlib_receiver) {
407+
return assert_lsp_strategy("main.ts", kTsInferredStdlibMethod,
408+
"lsp_ts_method");
409+
}
410+
398411
TEST(repro_lsp_ts_jsx) {
399412
return assert_lsp_strategy("app.tsx", kTsxJsx, "lsp_ts_jsx");
400413
}
@@ -429,6 +442,7 @@ SUITE(repro_lsp_ts) {
429442
RUN_TEST(repro_lsp_ts_namespace);
430443
RUN_TEST(repro_lsp_ts_import);
431444
RUN_TEST(repro_lsp_ts_inferred_import_receiver);
445+
RUN_TEST(repro_lsp_ts_inferred_stdlib_receiver);
432446
RUN_TEST(repro_lsp_ts_jsx);
433447
RUN_TEST(repro_lsp_ts_jsx_import);
434448
RUN_TEST(repro_lsp_ts_default);

0 commit comments

Comments
 (0)