From c16022586e80d679c9e93d787468a585600cb889 Mon Sep 17 00:00:00 2001 From: centauri <83140718+centau@users.noreply.github.com> Date: Mon, 3 Nov 2025 00:51:09 +0000 Subject: [PATCH] Add create type test --- test/create-types.luau | 70 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 test/create-types.luau diff --git a/test/create-types.luau b/test/create-types.luau new file mode 100644 index 0000000..3d387e3 --- /dev/null +++ b/test/create-types.luau @@ -0,0 +1,70 @@ +type Pseudo = { + Test: number +} + +type Instances = { + TextLabel: TextLabel, + TextButton: TextButton, + ImageLabel: ImageLabel, + Pseudo: Pseudo +} + +type function Properties(instance: type?) + local properties = types.newtable() + + while instance do + for i, v in instance:properties() do + local connector = v.read and v.read.tag == "table" and v.read:readproperty(types.singleton("Connect")) + if connector then + if not connector then continue end + local params = connector:parameters().head + if not params then continue end + local listener = params[2] + if not listener then continue end + properties:setproperty(i, types.optional(listener)) + elseif v.write then + properties:setproperty(i, types.optional(types.unionof( + v.write, + types.newfunction({}, { head = { v.write } }) + ))) + end + end + + instance = instance:readparent() + end + + properties:setindexer(types.number, types.any) + + return properties +end + +local function create(name: Name | keyof): (Properties>) -> index + return function() + return "" :: any + end +end + +local vide = require "../src/" +local count = vide.source(0) +create("TextButton") { + BackgroundTransparency = 1, + AnchorPoint = "bad value", -- should error + InvalidProperty = true, -- should error + + Text = function() + return "count: " .. count() + end, + + Size = function() -- should error + return "bad value" + end, + + MouseEnter = function(x, y) + + end, + + Activated = "bad value", -- should error + + create "TextLabel" {}, + function() end, +}