Refactor typedef files to ensure moonwave picks up functions

This commit is contained in:
Filip Tibell 2023-07-22 13:42:29 +02:00
parent 8c14c3cda3
commit 623af1c312
No known key found for this signature in database
7 changed files with 656 additions and 602 deletions

View file

@ -14,7 +14,7 @@ export type MetadataPermissions = {
readOnly: boolean,
}
-- FIXME: We lose doc comments here because of the union type
-- FIXME: We lose doc comments here below in Metadata because of the union type
--[=[
@interface Metadata
@ -87,7 +87,8 @@ export type WriteOptions = {
end
```
]=]
return {
local fs = {}
--[=[
@within FS
@tag must_use
@ -104,9 +105,10 @@ return {
@param path The path to the file to read
@return The contents of the file
]=]
readFile = function(path: string): string
function fs.readFile(path: string): string
return nil :: any
end,
end
--[=[
@within FS
@tag must_use
@ -122,9 +124,10 @@ return {
@param path The directory path to search in
@return A list of files & directories found
]=]
readDir = function(path: string): { string }
function fs.readDir(path: string): { string }
return {}
end,
end
--[=[
@within FS
@ -139,7 +142,8 @@ return {
@param path The path of the file
@param contents The contents of the file
]=]
writeFile = function(path: string, contents: string) end,
function fs.writeFile(path: string, contents: string) end
--[=[
@within FS
@ -153,7 +157,8 @@ return {
@param path The directory to create
]=]
writeDir = function(path: string) end,
function fs.writeDir(path: string) end
--[=[
@within FS
@ -167,7 +172,8 @@ return {
@param path The file to remove
]=]
removeFile = function(path: string) end,
function fs.removeFile(path: string) end
--[=[
@within FS
@ -181,7 +187,8 @@ return {
@param path The directory to remove
]=]
removeDir = function(path: string) end,
function fs.removeDir(path: string) end
--[=[
@within FS
@tag must_use
@ -196,9 +203,10 @@ return {
@param path The path to get metadata for
@return Metadata for the path
]=]
metadata = function(path: string): Metadata
function fs.metadata(path: string): Metadata
return nil :: any
end,
end
--[=[
@within FS
@tag must_use
@ -213,9 +221,10 @@ return {
@param path The file path to check
@return If the path is a file or not
]=]
isFile = function(path: string): boolean
function fs.isFile(path: string): boolean
return nil :: any
end,
end
--[=[
@within FS
@tag must_use
@ -230,9 +239,10 @@ return {
@param path The directory path to check
@return If the path is a directory or not
]=]
isDir = function(path: string): boolean
function fs.isDir(path: string): boolean
return nil :: any
end,
end
--[=[
@within FS
@ -252,7 +262,8 @@ return {
@param to The path to move to
@param overwriteOrOptions Options for the target path, such as if should be overwritten if it already exists
]=]
move = function(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end,
function fs.move(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end
--[=[
@within FS
@ -271,5 +282,6 @@ return {
@param to The path to copy to
@param overwriteOrOptions Options for the target path, such as if should be overwritten if it already exists
]=]
copy = function(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end,
}
function fs.copy(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end
return fs

View file

@ -196,7 +196,8 @@ export type WebSocket = {
end)
```
]=]
return {
local net = {}
--[=[
@within Net
@ -207,9 +208,10 @@ return {
@param config The URL or request config to use
@return A dictionary representing the response for the request
]=]
request = function(config: string | FetchParams): FetchResponse
function net.request(config: string | FetchParams): FetchResponse
return nil :: any
end,
end
--[=[
@within Net
@tag must_use
@ -222,9 +224,10 @@ return {
@param url The URL to connect to
@return A web socket handle
]=]
socket = function(url: string): WebSocket
function net.socket(url: string): WebSocket
return nil :: any
end,
end
--[=[
@within Net
@ -236,9 +239,10 @@ return {
@param port The port to use for the server
@param handlerOrConfig The handler function or config to use for the server
]=]
serve = function(port: number, handlerOrConfig: ServeHttpHandler | ServeConfig): ServeHandle
function net.serve(port: number, handlerOrConfig: ServeHttpHandler | ServeConfig): ServeHandle
return nil :: any
end,
end
--[=[
@within Net
@tag must_use
@ -249,9 +253,10 @@ return {
@param pretty If the encoded JSON string should include newlines and spaces. Defaults to false
@return The encoded JSON string
]=]
jsonEncode = function(value: any, pretty: boolean?): string
function net.jsonEncode(value: any, pretty: boolean?): string
return nil :: any
end,
end
--[=[
@within Net
@tag must_use
@ -261,9 +266,10 @@ return {
@param encoded The JSON string to decode
@return The decoded lua value
]=]
jsonDecode = function(encoded: string): any
function net.jsonDecode(encoded: string): any
return nil :: any
end,
end
--[=[
@within Net
@tag must_use
@ -274,9 +280,10 @@ return {
@param binary If the string should be treated as binary data and/or is not valid utf-8. Defaults to false
@return The encoded string
]=]
urlEncode = function(s: string, binary: boolean?): string
function net.urlEncode(s: string, binary: boolean?): string
return nil :: any
end,
end
--[=[
@within Net
@tag must_use
@ -287,7 +294,8 @@ return {
@param binary If the string should be treated as binary data and/or is not valid utf-8. Defaults to false
@return The decoded string
]=]
urlDecode = function(s: string, binary: boolean?): string
function net.urlDecode(s: string, binary: boolean?): string
return nil :: any
end,
}
end
return net

View file

@ -78,10 +78,11 @@ export type SpawnResult = {
end
```
]=]
return {
local process = {}
--[=[
@within Process
@read_only
@tag read_only
The current operating system being used.
@ -91,10 +92,11 @@ return {
* `"macos"`
* `"windows"`
]=]
os = (nil :: any) :: OS,
process.os = (nil :: any) :: OS
--[=[
@within Process
@read_only
@tag read_only
The architecture of the processor currently being used.
@ -103,21 +105,24 @@ return {
* `"x86_64"`
* `"aarch64"`
]=]
arch = (nil :: any) :: Arch,
process.arch = (nil :: any) :: Arch
--[=[
@within Process
@read_only
@tag read_only
The arguments given when running the Lune script.
]=]
args = (nil :: any) :: { string },
process.args = (nil :: any) :: { string }
--[=[
@within Process
@read_only
@tag read_only
The current working directory in which the Lune script is running.
]=]
cwd = (nil :: any) :: string,
process.cwd = (nil :: any) :: string
--[=[
@within Process
@read_write
@ -126,7 +131,8 @@ return {
Setting a value on this table will set the corresponding environment variable.
]=]
env = (nil :: any) :: { [string]: string? },
process.env = (nil :: any) :: { [string]: string? }
--[=[
@within Process
@ -138,7 +144,8 @@ return {
@param code The exit code to set
]=]
exit = function(code: number?) end,
function process.exit(code: number?) end
--[=[
@within Process
@ -154,7 +161,8 @@ return {
@param options A dictionary of options for the child process
@return A dictionary representing the result of the child process
]=]
spawn = function(program: string, params: { string }?, options: SpawnOptions?): SpawnResult
function process.spawn(program: string, params: { string }?, options: SpawnOptions?): SpawnResult
return nil :: any
end,
}
end
return process

View file

@ -213,7 +213,8 @@ export type DataModel =
fs.writeFile("myPlaceFile.rbxl", newPlaceFile)
```
]=]
return {
local roblox = {}
--[=[
@within Roblox
@tag must_use
@ -236,9 +237,10 @@ return {
@param contents The contents of the place to read
]=]
deserializePlace = function(contents: string): DataModel
function roblox.deserializePlace(contents: string): DataModel
return nil :: any
end,
end
--[=[
@within Roblox
@tag must_use
@ -261,9 +263,10 @@ return {
@param contents The contents of the model to read
]=]
deserializeModel = function(contents: string): { Instance }
function roblox.deserializeModel(contents: string): { Instance }
return nil :: any
end,
end
--[=[
@within Roblox
@tag must_use
@ -285,9 +288,10 @@ return {
@param dataModel The DataModel for the place to serialize
@param xml If the place should be serialized as xml or not. Defaults to `false`, meaning the place gets serialized using the binary format and not xml.
]=]
serializePlace = function(dataModel: DataModel, xml: boolean?): string
function roblox.serializePlace(dataModel: DataModel, xml: boolean?): string
return nil :: any
end,
end
--[=[
@within Roblox
@tag must_use
@ -309,9 +313,10 @@ return {
@param instances The array of instances to serialize
@param xml If the model should be serialized as xml or not. Defaults to `false`, meaning the model gets serialized using the binary format and not xml.
]=]
serializeModel = function(instances: { Instance }, xml: boolean?): string
function roblox.serializeModel(instances: { Instance }, xml: boolean?): string
return nil :: any
end,
end
--[=[
@within Roblox
@tag must_use
@ -348,9 +353,10 @@ return {
@param raw If the cookie should be returned as a pure value or not. Defaults to false
]=]
getAuthCookie = function(raw: boolean?): string?
function roblox.getAuthCookie(raw: boolean?): string?
return nil :: any
end,
end
--[=[
@within Roblox
@tag must_use
@ -381,11 +387,13 @@ return {
end
```
]=]
getReflectionDatabase = function(): Database
function roblox.getReflectionDatabase(): Database
return nil :: any
end,
end
-- TODO: Make typedefs for all of the datatypes as well...
Instance = (nil :: any) :: {
roblox.Instance = (nil :: any) :: {
new: ((className: "DataModel") -> DataModel) & ((className: string) -> Instance),
},
}
return roblox

View file

@ -27,7 +27,8 @@ export type CompressDecompressFormat = "brotli" | "gzip" | "lz4" | "zlib"
fs.writeFile("myFile.yaml", serde.encode("yaml", someYaml))
```
]=]
return {
local serde = {}
--[=[
@within Serde
@tag must_use
@ -47,9 +48,10 @@ return {
@param pretty If the encoded string should be human-readable, including things such as newlines and spaces. Only supported for json and toml formats, and defaults to false
@return The encoded string
]=]
encode = function(format: EncodeDecodeFormat, value: any, pretty: boolean?): string
function serde.encode(format: EncodeDecodeFormat, value: any, pretty: boolean?): string
return nil :: any
end,
end
--[=[
@within Serde
@tag must_use
@ -68,9 +70,10 @@ return {
@param encoded The string to decode
@return The decoded lua value
]=]
decode = function(format: EncodeDecodeFormat, encoded: string): any
function serde.decode(format: EncodeDecodeFormat, encoded: string): any
return nil :: any
end,
end
--[=[
@within Serde
@tag must_use
@ -90,9 +93,10 @@ return {
@param encoded The string to compress
@return The compressed string
]=]
compress = function(format: CompressDecompressFormat, s: string): string
function serde.compress(format: CompressDecompressFormat, s: string): string
return nil :: any
end,
end
--[=[
@within Serde
@tag must_use
@ -112,7 +116,8 @@ return {
@param encoded The string to decompress
@return The decompressed string
]=]
decompress = function(format: CompressDecompressFormat, s: string): string
function serde.decompress(format: CompressDecompressFormat, s: string): string
return nil :: any
end,
}
end
return serde

View file

@ -60,7 +60,10 @@ end
stdio.ewrite("\nAnd some error text, too")
```
]=]
return {
local stdio = {}
stdio.prompt = prompt
--[=[
@within Stdio
@tag must_use
@ -81,9 +84,10 @@ return {
@param color The color to use
@return A printable ANSI string
]=]
color = function(color: Color): string
function stdio.color(color: Color): string
return nil :: any
end,
end
--[=[
@within Stdio
@tag must_use
@ -104,9 +108,10 @@ return {
@param style The style to use
@return A printable ANSI string
]=]
style = function(style: Style): string
function stdio.style(style: Style): string
return nil :: any
end,
end
--[=[
@within Stdio
@tag must_use
@ -116,9 +121,10 @@ return {
@param ... The values to format
@return The formatted string
]=]
format = function(...: any): string
function stdio.format(...: any): string
return nil :: any
end,
end
--[=[
@within Stdio
@ -126,7 +132,8 @@ return {
@param s The string to write to stdout
]=]
write = function(s: string) end,
function stdio.write(s: string) end
--[=[
@within Stdio
@ -134,6 +141,6 @@ return {
@param s The string to write to stderr
]=]
ewrite = function(s: string) end,
prompt = prompt,
}
function stdio.ewrite(s: string) end
return stdio

View file

@ -27,7 +27,8 @@
print("Running after task.spawn yields")
```
]=]
return {
local task = {}
--[=[
@within Task
@ -35,7 +36,8 @@ return {
@param thread The thread to cancel
]=]
cancel = function(thread: thread) end,
function task.cancel(thread: thread) end
--[=[
@within Task
@ -44,9 +46,10 @@ return {
@param functionOrThread The function or thread to defer
@return The thread that will be deferred
]=]
defer = function<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread
function task.defer<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread
return nil :: any
end,
end
--[=[
@within Task
@ -57,13 +60,14 @@ return {
@param functionOrThread The function or thread to delay
@return The thread that will be delayed
]=]
delay = function<T...>(
function task.delay<T...>(
duration: number?,
functionOrThread: thread | (T...) -> ...any,
...: T...
): thread
return nil :: any
end,
end
--[=[
@within Task
@ -75,9 +79,10 @@ return {
@param functionOrThread The function or thread to spawn
@return The thread that was spawned
]=]
spawn = function<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread
function task.spawn<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread
return nil :: any
end,
end
--[=[
@within Task
@ -89,7 +94,8 @@ return {
@param duration The amount of time to wait
@return The exact amount of time waited
]=]
wait = function(duration: number?): number
function task.wait(duration: number?): number
return nil :: any
end,
}
end
return task