From b78890b5f024f34612ce11dc70d14669f92ebf15 Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Sun, 3 Mar 2024 15:12:46 +0100 Subject: [PATCH] Fix types dump (#562) * Regenerate types file in CI Make sure changes to the python script are appropriately tested * Fix RaycastResult definition * Move RaycastResult definition The default generic type 'Instance' needs to be defined first --- .github/workflows/ci.yml | 5 +++++ scripts/dumpRobloxTypes.py | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f468b69..2d639838 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,11 @@ jobs: cmake .. cmake --build . --target Luau.LanguageServer.CLI -j 3 + - name: Regenerate Types + run: | + cd scripts + python dumpRobloxTypes.py > globalTypes.d.luau + - name: Test types run: | touch test.lua diff --git a/scripts/dumpRobloxTypes.py b/scripts/dumpRobloxTypes.py index 8bbf65ab..003079e6 100644 --- a/scripts/dumpRobloxTypes.py +++ b/scripts/dumpRobloxTypes.py @@ -64,7 +64,7 @@ "EnumItem", # redefined explicitly "GlobalSettings", # redefined explicitly "SharedTable", # redefined explicitly as the RobloxLsp type is incomplete - "RaycastResult", # Redefined using generics + "RaycastResult", # Redefined using generics ] # Methods / Properties ignored in classes. Commonly used to add corrections @@ -617,14 +617,6 @@ Once: (self: RBXScriptSignal, callback: (T...) -> ()) -> RBXScriptConnection, } -export type RaycastResult = { - Instance: T, - Position: Vector3, - Normal: Vector3, - Distance: number, - Material: Enum.Material, -} - type HttpRequestOptions = { Url: string, Method: "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "PATCH" | nil, @@ -676,6 +668,14 @@ update: (st: SharedTable, key: string | number, f: (any) -> any) -> (), } +export type RaycastResult = { + Instance: T, + Position: Vector3, + Normal: Vector3, + Distance: number, + Material: EnumMaterial, +} + declare game: DataModel declare workspace: Workspace declare plugin: Plugin @@ -1168,9 +1168,9 @@ def applyCorrections(dump: ApiDump, corrections: CorrectionsDump): else otherParam["Type"]["Name"] ) if "Generic" in param["Type"]: - otherParam["Type"][ - "Generic" - ] = param["Type"]["Generic"] + otherParam["Type"]["Generic"] = ( + param["Type"]["Generic"] + ) if "Default" in param: otherParam["Default"] = param["Default"]