feat: Create local variable to allow for method definitions

This commit is contained in:
2025-09-17 01:27:59 +02:00
parent 6086dec859
commit ebea44e70c
4 changed files with 13 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ pub struct A {
fn flatten() {
insta::assert_snapshot!(<A as Typed>::generate_full().unwrap(), @r"
---@class A
local A
---@field hello string
---@field world boolean
---@field cool integer

View File

@@ -14,6 +14,7 @@ pub enum ActionType {
fn action_type() {
insta::assert_snapshot!(<ActionType as Typed>::generate_full().unwrap(), @r#"
---@class ActionType
local ActionType
---@field action
---| "broadcast"
---@field extras table<string, string>?
@@ -55,6 +56,7 @@ pub struct Action {
fn action() {
insta::assert_snapshot!(<Action as Typed>::generate_full().unwrap(), @r#"
---@class Action
local Action
---@field action
---| "broadcast"
---@field extras table<string, string>?
@@ -78,6 +80,7 @@ pub struct Notification {
fn notification() {
insta::assert_snapshot!(<Notification as Typed>::generate_full().unwrap(), @r"
---@class Notification
local Notification
---@field title string
---@field message string?
---@field tags string[]?

View File

@@ -11,13 +11,17 @@ struct Other {
#[test]
fn rename() {
insta::assert_snapshot!(<Rust as Typed>::generate_full().unwrap(), @"---@class Lua");
insta::assert_snapshot!(<Rust as Typed>::generate_full().unwrap(), @r"
---@class Lua
local Lua
");
}
#[test]
fn rename_nested() {
insta::assert_snapshot!(<Other as Typed>::generate_full().unwrap(), @r"
---@class Other
local Other
---@field rust Lua
");
}