Skip to content
Discussion options

You must be logged in to vote

There are various ways this can be done.

You can simply add a file in your workspace, say, under types/ and add the following:

---@meta

---@generic T: table
---@param t T
---@return T
table.deepcopy = function(t) end

Using generics allows more detailed information retrieved from the given table to persist in the returned value. A simpler version, if generics aren't working for you, is just the following:

---@meta

---@param t table
---@return table
table.deepcopy = function(t) end

So long as that file is included in diagnostics and is not being excluded via your settings, that should do it.

A cleaner solution would be to put that file somewhere outside your project, and then point to it …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by QuingKhaos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
feat/diagnostics Related to the diagnostics feature
2 participants