Skip to content

Commit

Permalink
Fix types dump (#562)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JohnnyMorganz authored Mar 3, 2024
1 parent 799f09b commit b78890b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions scripts/dumpRobloxTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -617,14 +617,6 @@
Once: (self: RBXScriptSignal<T...>, callback: (T...) -> ()) -> RBXScriptConnection,
}
export type RaycastResult<T = Instance> = {
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,
Expand Down Expand Up @@ -676,6 +668,14 @@
update: (st: SharedTable, key: string | number, f: (any) -> any) -> (),
}
export type RaycastResult<T = Instance> = {
Instance: T,
Position: Vector3,
Normal: Vector3,
Distance: number,
Material: EnumMaterial,
}
declare game: DataModel
declare workspace: Workspace
declare plugin: Plugin
Expand Down Expand Up @@ -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"]

Expand Down

0 comments on commit b78890b

Please sign in to comment.