diff --git a/docs/typedefs/Roblox.luau b/docs/typedefs/Roblox.luau index d32d911..9a9432f 100644 --- a/docs/typedefs/Roblox.luau +++ b/docs/typedefs/Roblox.luau @@ -2,7 +2,8 @@ type InstanceProperties = { Parent: Instance?, ClassName: string, Name: string, - -- FIXME: This breaks intellisense, but we need some way to access instance properties... + -- FIXME: This breaks intellisense, but we need some way to access + -- instance properties without casting the entire instance to any... -- [string]: any, } @@ -218,4 +219,8 @@ return { getAuthCookie = function(raw: boolean?): string? return nil :: any end, + -- TODO: Make typedefs for all of the datatypes as well... + Instance = (nil :: any) :: { + new: ((className: "DataModel") -> DataModel) & ((className: string) -> Instance), + }, } diff --git a/tests/roblox/files/deserializeModel.luau b/tests/roblox/files/deserializeModel.luau index 7a965b5..39bf4d4 100644 --- a/tests/roblox/files/deserializeModel.luau +++ b/tests/roblox/files/deserializeModel.luau @@ -1,5 +1,5 @@ local fs = require("@lune/fs") -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local modelDirs = {} for _, dirName in fs.readDir("tests/roblox/rbx-test-files/places") do diff --git a/tests/roblox/files/deserializePlace.luau b/tests/roblox/files/deserializePlace.luau index 02da733..e1cbd19 100644 --- a/tests/roblox/files/deserializePlace.luau +++ b/tests/roblox/files/deserializePlace.luau @@ -1,5 +1,5 @@ local fs = require("@lune/fs") -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local placeDirs = {} for _, dirName in fs.readDir("tests/roblox/rbx-test-files/places") do diff --git a/tests/roblox/files/serializeModel.luau b/tests/roblox/files/serializeModel.luau index 3c02d79..3bebc1c 100644 --- a/tests/roblox/files/serializeModel.luau +++ b/tests/roblox/files/serializeModel.luau @@ -1,5 +1,5 @@ local fs = require("@lune/fs") -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local instances = { diff --git a/tests/roblox/files/serializePlace.luau b/tests/roblox/files/serializePlace.luau index dd3d51d..5dfdfbe 100644 --- a/tests/roblox/files/serializePlace.luau +++ b/tests/roblox/files/serializePlace.luau @@ -1,5 +1,5 @@ local fs = require("@lune/fs") -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local game = Instance.new("DataModel") diff --git a/tests/roblox/instance/classes/DataModel.luau b/tests/roblox/instance/classes/DataModel.luau index 5567c54..c0cb53a 100644 --- a/tests/roblox/instance/classes/DataModel.luau +++ b/tests/roblox/instance/classes/DataModel.luau @@ -1,18 +1,19 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local game = Instance.new("DataModel") -- Workspace should always exist as a "Workspace" property, or be created when accessed -assert(game.Workspace ~= nil) -assert(game.Workspace:IsA("Workspace")) -assert(game.Workspace == game:FindFirstChildOfClass("Workspace")) +local workspace = (game :: any).Workspace +assert(workspace ~= nil) +assert(workspace:IsA("Workspace")) +assert(workspace == game:FindFirstChildOfClass("Workspace")) -- GetService and FindService should work, GetService should create services that don't exist assert(game:FindService("CSGDictionaryService") == nil) -assert(game:GetService("CSGDictionaryService") ~= nil) +assert(game:GetService("CSGDictionaryService")) assert(game:FindService("CSGDictionaryService") ~= nil) -- Service names should be strict and not allow weird characters or substrings diff --git a/tests/roblox/instance/classes/Workspace.luau b/tests/roblox/instance/classes/Workspace.luau index 523a1fa..5813bc7 100644 --- a/tests/roblox/instance/classes/Workspace.luau +++ b/tests/roblox/instance/classes/Workspace.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local game = Instance.new("DataModel") @@ -6,12 +6,14 @@ local workspace = game:GetService("Workspace") -- Terrain should always exist as a "Terrain" property, or be created when accessed -assert(workspace.Terrain ~= nil) -assert(workspace.Terrain:IsA("Terrain")) -assert(workspace.Terrain == workspace:FindFirstChildOfClass("Terrain")) +local terrain = (workspace :: any).Terrain +assert(terrain ~= nil) +assert(terrain:IsA("Terrain")) +assert(terrain == workspace:FindFirstChildOfClass("Terrain")) -- Camera should always exist as a "CurrentCamera" property, or be created when accessed -assert(workspace.CurrentCamera ~= nil) -assert(workspace.CurrentCamera:IsA("Camera")) -assert(workspace.CurrentCamera == workspace:FindFirstChildOfClass("Camera")) +local camera = (workspace :: any).CurrentCamera +assert(camera ~= nil) +assert(camera:IsA("Camera")) +assert(camera == workspace:FindFirstChildOfClass("Camera")) diff --git a/tests/roblox/instance/methods/ClearAllChildren.luau b/tests/roblox/instance/methods/ClearAllChildren.luau index dad9ce9..ed6ec22 100644 --- a/tests/roblox/instance/methods/ClearAllChildren.luau +++ b/tests/roblox/instance/methods/ClearAllChildren.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local root = Instance.new("Model") diff --git a/tests/roblox/instance/methods/Clone.luau b/tests/roblox/instance/methods/Clone.luau index 6189dce..0472974 100644 --- a/tests/roblox/instance/methods/Clone.luau +++ b/tests/roblox/instance/methods/Clone.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local root = Instance.new("Model") @@ -7,9 +7,9 @@ local objValue1 = Instance.new("ObjectValue") local objValue2 = Instance.new("ObjectValue") objValue1.Name = "ObjectValue1" -objValue2.Name = "ObjectValue2" -objValue1.Value = root -objValue2.Value = child +objValue2.Name = "ObjectValue2"; +(objValue1 :: any).Value = root; +(objValue2 :: any).Value = child objValue1.Parent = child objValue2.Parent = child child.Parent = root diff --git a/tests/roblox/instance/methods/Destroy.luau b/tests/roblox/instance/methods/Destroy.luau index 113fead..aa18344 100644 --- a/tests/roblox/instance/methods/Destroy.luau +++ b/tests/roblox/instance/methods/Destroy.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local root = Instance.new("Folder") diff --git a/tests/roblox/instance/methods/FindFirstAncestor.luau b/tests/roblox/instance/methods/FindFirstAncestor.luau index c0b5fc2..60a0425 100644 --- a/tests/roblox/instance/methods/FindFirstAncestor.luau +++ b/tests/roblox/instance/methods/FindFirstAncestor.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local root = Instance.new("Folder") diff --git a/tests/roblox/instance/methods/FindFirstAncestorOfClass.luau b/tests/roblox/instance/methods/FindFirstAncestorOfClass.luau index 1f68f5e..ccef54b 100644 --- a/tests/roblox/instance/methods/FindFirstAncestorOfClass.luau +++ b/tests/roblox/instance/methods/FindFirstAncestorOfClass.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local root = Instance.new("Folder") diff --git a/tests/roblox/instance/methods/FindFirstAncestorWhichIsA.luau b/tests/roblox/instance/methods/FindFirstAncestorWhichIsA.luau index a7322b5..6e8f3d9 100644 --- a/tests/roblox/instance/methods/FindFirstAncestorWhichIsA.luau +++ b/tests/roblox/instance/methods/FindFirstAncestorWhichIsA.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local root = Instance.new("Folder") diff --git a/tests/roblox/instance/methods/FindFirstChild.luau b/tests/roblox/instance/methods/FindFirstChild.luau index 8f1f3e4..02ca02b 100644 --- a/tests/roblox/instance/methods/FindFirstChild.luau +++ b/tests/roblox/instance/methods/FindFirstChild.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local root = Instance.new("Folder") diff --git a/tests/roblox/instance/methods/FindFirstChildOfClass.luau b/tests/roblox/instance/methods/FindFirstChildOfClass.luau index 55b12d4..2249043 100644 --- a/tests/roblox/instance/methods/FindFirstChildOfClass.luau +++ b/tests/roblox/instance/methods/FindFirstChildOfClass.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local root = Instance.new("Folder") diff --git a/tests/roblox/instance/methods/FindFirstChildWhichIsA.luau b/tests/roblox/instance/methods/FindFirstChildWhichIsA.luau index 087ce1d..f480a82 100644 --- a/tests/roblox/instance/methods/FindFirstChildWhichIsA.luau +++ b/tests/roblox/instance/methods/FindFirstChildWhichIsA.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local root = Instance.new("Folder") diff --git a/tests/roblox/instance/methods/GetChildren.luau b/tests/roblox/instance/methods/GetChildren.luau index dc6f824..87e2618 100644 --- a/tests/roblox/instance/methods/GetChildren.luau +++ b/tests/roblox/instance/methods/GetChildren.luau @@ -1,5 +1,5 @@ local fs = require("@lune/fs") -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local modelFile = fs.readFile("tests/roblox/rbx-test-files/models/three-nested-folders/binary.rbxm") diff --git a/tests/roblox/instance/methods/GetDescendants.luau b/tests/roblox/instance/methods/GetDescendants.luau index 58c0cf4..43701fc 100644 --- a/tests/roblox/instance/methods/GetDescendants.luau +++ b/tests/roblox/instance/methods/GetDescendants.luau @@ -1,5 +1,5 @@ local fs = require("@lune/fs") -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local modelFile = fs.readFile("tests/roblox/rbx-test-files/models/three-nested-folders/binary.rbxm") diff --git a/tests/roblox/instance/methods/GetFullName.luau b/tests/roblox/instance/methods/GetFullName.luau index f249e77..17be47e 100644 --- a/tests/roblox/instance/methods/GetFullName.luau +++ b/tests/roblox/instance/methods/GetFullName.luau @@ -1,11 +1,13 @@ local fs = require("@lune/fs") -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local modelFile = fs.readFile("tests/roblox/rbx-test-files/models/three-nested-folders/binary.rbxm") local model = roblox.deserializeModel(modelFile)[1] local child = model:FindFirstChild("Parent") +assert(child ~= nil) local descendant = child:FindFirstChild("Child") +assert(descendant ~= nil) assert(descendant:GetFullName() == "Grandparent.Parent.Child") assert(child:GetFullName() == "Grandparent.Parent") diff --git a/tests/roblox/instance/methods/IsA.luau b/tests/roblox/instance/methods/IsA.luau index 1732af4..05a5fbf 100644 --- a/tests/roblox/instance/methods/IsA.luau +++ b/tests/roblox/instance/methods/IsA.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local part = Instance.new("Part") diff --git a/tests/roblox/instance/methods/IsAncestorOf.luau b/tests/roblox/instance/methods/IsAncestorOf.luau index a482c97..b5e0007 100644 --- a/tests/roblox/instance/methods/IsAncestorOf.luau +++ b/tests/roblox/instance/methods/IsAncestorOf.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local root = Instance.new("Folder") diff --git a/tests/roblox/instance/methods/IsDescendantOf.luau b/tests/roblox/instance/methods/IsDescendantOf.luau index 8a65c64..4b7df2a 100644 --- a/tests/roblox/instance/methods/IsDescendantOf.luau +++ b/tests/roblox/instance/methods/IsDescendantOf.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local root = Instance.new("Folder") diff --git a/tests/roblox/instance/new.luau b/tests/roblox/instance/new.luau index 428ff73..cb5c362 100644 --- a/tests/roblox/instance/new.luau +++ b/tests/roblox/instance/new.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance -- Should not allow creating unknown classes @@ -33,7 +33,7 @@ assert(model.Parent == nil) -- Parenting and indexing should work model.Parent = folder assert(model.Parent == folder) -assert(folder.Model == model) +assert((folder :: any).Model == model) -- Parenting to nil should work model.Parent = nil @@ -43,6 +43,6 @@ assert(model.Parent == nil) model.Name = "MyCoolModel" assert(model.Name == "MyCoolModel") assert(not pcall(function() - model.Name = nil + model.Name = nil :: any end)) assert(model.Name == "MyCoolModel") diff --git a/tests/roblox/instance/tags.luau b/tests/roblox/instance/tags.luau index da1c6d3..f3b6c2b 100644 --- a/tests/roblox/instance/tags.luau +++ b/tests/roblox/instance/tags.luau @@ -1,4 +1,4 @@ -local roblox = require("@lune/roblox") :: any +local roblox = require("@lune/roblox") local Instance = roblox.Instance local model = Instance.new("Model")