@@ -307,4 +307,92 @@ TEST_CASE_FIXTURE(Fixture, "includes_documentation_for_a_function_call")
307307 CHECK_EQ (result->contents .value , codeBlock (" luau" , " function foo(): ()" ) + kDocumentationBreaker + " This is documentation for Foo\n " );
308308}
309309
310+ TEST_CASE_FIXTURE (Fixture, " includes_documentation_for_type_alias_declarations" )
311+ {
312+ auto source = R"(
313+ --- The metre (or meter in [US spelling]; symbol: m) is the [base unit] of [length]
314+ --- in the [International System of Units] (SI)
315+ export type Meters = number
316+ )" ;
317+
318+ auto uri = newDocument (" meters.luau" , source);
319+
320+ lsp::HoverParams params;
321+ params.textDocument = lsp::TextDocumentIdentifier{uri};
322+ params.position = lsp::Position{3 , 21 };
323+
324+ auto result = workspace.hover (params);
325+ REQUIRE (result);
326+ CHECK_EQ (
327+ result->contents .value ,
328+ codeBlock (" luau" , " type Meters = number" ) +
329+ kDocumentationBreaker +
330+ " The metre (or meter in [US spelling]; symbol: m) is the [base unit] of [length]\n " +
331+ " in the [International System of Units] (SI)\n "
332+ );
333+ }
334+
335+ TEST_CASE_FIXTURE (Fixture, " includes_documentation_for_type_alias_declarations_of_intersected_tables" )
336+ {
337+ auto source = R"(
338+ type Foo = {
339+ foo: "Foo",
340+ }
341+
342+ type Bar = {
343+ bar: "Bar",
344+ }
345+
346+ --- The terms foobar (/ˈfuːbɑːr/), foo, bar, baz, qux, quux, and others are used as
347+ --- metasyntactic variables and placeholder names in computer programming or computer-related documentation
348+ export type Foobar = Foo & Bar
349+ )" ;
350+
351+ auto uri = newDocument (" meters.luau" , source);
352+
353+ lsp::HoverParams params;
354+ params.textDocument = lsp::TextDocumentIdentifier{uri};
355+ params.position = lsp::Position{11 , 21 };
356+
357+ auto result = workspace.hover (params);
358+ REQUIRE (result);
359+ CHECK_EQ (
360+ result->contents .value ,
361+ codeBlock (" luau" , " type Foobar = {\n bar: \" Bar\"\n } & {\n foo: \" Foo\"\n }" ) +
362+ kDocumentationBreaker +
363+ " The terms foobar (/ˈfuːbɑːr/), foo, bar, baz, qux, quux, and others are used as\n " +
364+ " metasyntactic variables and placeholder names in computer programming or computer-related documentation\n "
365+ );
366+ }
367+
368+ TEST_CASE_FIXTURE (Fixture, " includes_documentation_for_type_references" )
369+ {
370+ auto source = R"(
371+ type Foo = {
372+ foo: "Foo",
373+ }
374+
375+ type Bar = {
376+ bar: "Bar",
377+ }
378+
379+ --- This is the intersection of two types
380+ export type Foobar = Foo & Bar
381+
382+ function consumer(value: Foobar)
383+ end
384+ )" ;
385+
386+ auto uri = newDocument (" meters.luau" , source);
387+
388+ lsp::HoverParams params;
389+ params.textDocument = lsp::TextDocumentIdentifier{uri};
390+ params.position = lsp::Position{12 , 36 };
391+
392+ auto result = workspace.hover (params);
393+ REQUIRE (result);
394+ CHECK_EQ (result->contents .value , codeBlock (" luau" , " type Foobar = {\n bar: \" Bar\"\n } & {\n foo: \" Foo\"\n }" ) + kDocumentationBreaker +
395+ " This is the intersection of two types\n " );
396+ }
397+
310398TEST_SUITE_END ();
0 commit comments