Skip to content

Commit

Permalink
Improve typing
Browse files Browse the repository at this point in the history
  • Loading branch information
hoontee committed Nov 22, 2023
1 parent 1b0bdd5 commit af61010
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions Pronghorn/New.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ local QUEUED_EVENT_QUEUE_SIZE = 256
--- @error Parent parameter used more than once -- Incorrect usage.
--- @error Name parameter used more than once -- Incorrect usage.
--- @error Properties parameter used more than once -- Incorrect usage.
function New.Instance(className: string, ...: any?): any
local parent: Instance?, name: string?, properties: {[string]: any, Children: {Instance}?}?
function New.Instance(className: string, ...: (Instance | string | {[string]: any, Children: {Instance}?, Attributes: {[string]: any}?, Tags: {string}?})?): any
local parent: Instance?, name: string?, properties: {[string]: any, Children: {Instance}?, Attributes: {[string]: any}?, Tags: {string}?}?;
for _, parameter in {...} do
if typeof(parameter) == "Instance" then
if parent then error("Parent parameter used more than once") end
Expand Down Expand Up @@ -93,19 +93,20 @@ function New.Instance(className: string, ...: any?): any
return newInstance
end

--- Clones and returns and Instance.
--- Clones and returns an Instance.
--- @param instance -- The Instance to clone from.
--- @param parent? -- The Parent for the cloned Instance after creation.
--- @param name? -- The Name for the cloned Instance.
--- @param properties? -- A table of properties to apply to the cloned Instance.
--- @return Instance -- The cloned Instance.
--- @error Attempt to clone non-Instance -- Incorrect usage.
--- @error Parent parameter used more than once -- Incorrect usage.
--- @error Name parameter used more than once -- Incorrect usage.
--- @error Properties parameter used more than once -- Incorrect usage.
function New.Clone<T>(instance: T, ...: any?): T
function New.Clone<T>(instance: T, ...: (Instance | string | {[string]: any, Children: {Instance}?, Attributes: {[string]: any}?, Tags: {string}?})?): T
assert(typeof(instance) == "Instance", "Attempt to clone non-Instance")

local parent: Instance?, name: string?, properties: {[string]: any, Children: {Instance}?}?
local parent: Instance?, name: string?, properties: {[string]: any, Children: {Instance}?, Attributes: {[string]: any}?, Tags: {string}?}?;
for _, parameter in {...} do
if typeof(parameter) == "Instance" then
if parent then error("Parent parameter used more than once") end
Expand Down
2 changes: 1 addition & 1 deletion Pronghorn/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
║ ██████▀██▓▌▀▌ ▄ ▄▓▌▐▓█▌ ║
║ ║
║ ║
║ Pronghorn Framework Rev. B49
║ Pronghorn Framework Rev. B50
║ https://github.com/Iron-Stag-Games/Pronghorn ║
║ GNU Lesser General Public License v2.1 ║
║ ║
Expand Down

0 comments on commit af61010

Please sign in to comment.