Skip to content

Commit 308e0c4

Browse files
committed
fix: Add types to packages
1 parent 24b5fbb commit 308e0c4

File tree

307 files changed

+4624
-3255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+4624
-3255
lines changed

src/acceltween/src/Shared/AccelTween.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
--!nocheck
12
--[=[
23
Provides a means to, with both a continuous position and velocity,
34
accelerate from its current position to a target position in minimum time

src/adorneeboundingbox/src/Shared/AdorneeBoundingBox.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ local AdorneeBoundingBox = setmetatable({}, BaseObject)
1818
AdorneeBoundingBox.ClassName = "AdorneeBoundingBox"
1919
AdorneeBoundingBox.__index = AdorneeBoundingBox
2020

21-
function AdorneeBoundingBox.new(initialAdornee)
21+
function AdorneeBoundingBox.new(initialAdornee: Instance)
2222
local self = setmetatable(BaseObject.new(), AdorneeBoundingBox)
2323

2424
self._adornee = self._maid:Add(ValueObject.new(initialAdornee))
@@ -41,7 +41,7 @@ function AdorneeBoundingBox.new(initialAdornee)
4141
return self
4242
end
4343

44-
function AdorneeBoundingBox:SetAdornee(adornee)
44+
function AdorneeBoundingBox:SetAdornee(adornee: Instance?)
4545
assert(typeof(adornee) == "Instance" or adornee == nil, "Bad adornee")
4646

4747
self._adornee.Value = adornee
@@ -90,7 +90,7 @@ end
9090
Gets the CFrame of the adornee
9191
@return Vector3
9292
]=]
93-
function AdorneeBoundingBox:GetCFrame()
93+
function AdorneeBoundingBox:GetCFrame(): CFrame?
9494
return self._bbCFrame.Value
9595
end
9696

@@ -106,7 +106,7 @@ end
106106
Gets the size of the adornee
107107
@return Vector3
108108
]=]
109-
function AdorneeBoundingBox:GetSize()
109+
function AdorneeBoundingBox:GetSize(): Vector3
110110
return self._bbSize.Value
111111
end
112112

@@ -153,7 +153,7 @@ function AdorneeBoundingBox:_setupTool(tool)
153153
return topMaid
154154
end
155155

156-
function AdorneeBoundingBox:_setupModel(model)
156+
function AdorneeBoundingBox:_setupModel(model: Model)
157157
assert(typeof(model) == "Instance" and model:IsA("Model"), "Bad model")
158158

159159
local topMaid = Maid.new()
@@ -190,7 +190,7 @@ function AdorneeBoundingBox:_setupHumanoid(humanoid: Humanoid)
190190
return topMaid
191191
end
192192

193-
function AdorneeBoundingBox:_setupAttachment(attachment)
193+
function AdorneeBoundingBox:_setupAttachment(attachment: Attachment)
194194
assert(typeof(attachment) == "Instance" and attachment:IsA("Attachment"), "Bad attachment")
195195

196196
local maid = Maid.new()
@@ -224,7 +224,7 @@ function AdorneeBoundingBox:_setupAttachment(attachment)
224224
return maid
225225
end
226226

227-
function AdorneeBoundingBox:_setupPart(part)
227+
function AdorneeBoundingBox:_setupPart(part: BasePart)
228228
assert(typeof(part) == "Instance" and part:IsA("BasePart"), "Bad part")
229229

230230
local maid = Maid.new()

src/adorneeboundingbox/src/Shared/AdorneeModelBoundingBox.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ local AdorneeModelBoundingBox = setmetatable({}, BaseObject)
1717
AdorneeModelBoundingBox.ClassName = "AdorneeModelBoundingBox"
1818
AdorneeModelBoundingBox.__index = AdorneeModelBoundingBox
1919

20-
function AdorneeModelBoundingBox.new(model)
20+
function AdorneeModelBoundingBox.new(model: Model)
2121
local self = setmetatable(BaseObject.new(model), AdorneeModelBoundingBox)
2222

2323
self._bbCFrame = self._maid:Add(ValueObject.new(nil))

src/adorneeboundingbox/src/Shared/AdorneePartBoundingBox.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ local AdorneePartBoundingBox = setmetatable({}, BaseObject)
1414
AdorneePartBoundingBox.ClassName = "AdorneePartBoundingBox"
1515
AdorneePartBoundingBox.__index = AdorneePartBoundingBox
1616

17-
function AdorneePartBoundingBox.new(part)
17+
function AdorneePartBoundingBox.new(part: BasePart)
1818
assert(typeof(part) == "Instance" and part:IsA("BasePart"), "Bad part")
1919

2020
local self = setmetatable(BaseObject.new(part), AdorneePartBoundingBox)

src/adorneeboundingbox/src/Shared/RxPartBoundingBoxUtils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local RxInstanceUtils = require("RxInstanceUtils")
88

99
local RxPartBoundingBoxUtils = {}
1010

11-
function RxPartBoundingBoxUtils.observePartCFrame(part)
11+
function RxPartBoundingBoxUtils.observePartCFrame(part: BasePart)
1212
assert(typeof(part) == "Instance" and part:IsA("BasePart"), "Bad part")
1313

1414
return RxInstanceUtils.observeProperty(part, "CFrame")

src/adorneedata/src/Shared/AdorneeData.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ AdorneeData.__index = AdorneeData
8989
@param prototype any
9090
@return AdorneeData<T>
9191
]=]
92-
function AdorneeData.new(prototype)
92+
function AdorneeData.new(prototype: any)
9393
local self = setmetatable({}, AdorneeData)
9494

9595
self._fullPrototype = assert(prototype, "Bad prototype")
@@ -128,6 +128,8 @@ function AdorneeData:__index(index)
128128
return AttributeValue.new(adornee, index, found)
129129
end, found)
130130
end
131+
else
132+
error("Bad index")
131133
end
132134
end
133135

@@ -138,7 +140,7 @@ end
138140
@return boolean
139141
@return string -- Error message
140142
]=]
141-
function AdorneeData:IsStrictData(data)
143+
function AdorneeData:IsStrictData(data): (boolean, string?)
142144
return self:GetStrictTInterface()(data)
143145
end
144146

src/adorneedata/src/Shared/AdorneeDataEntry.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ end
6464
@param data any
6565
@return boolean
6666
]=]
67-
function AdorneeDataEntry.isAdorneeDataEntry(data)
67+
function AdorneeDataEntry.isAdorneeDataEntry(data: any): boolean
6868
return DuckTypeUtils.isImplementation(AdorneeDataEntry, data)
6969
end
7070

src/adorneeutils/src/Shared/AdorneeUtils.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
--!strict
12
--[=[
23
Utilities involving an "Adornee" effectively, any Roblox instance. This is an extremely
34
useful library to use as it lets you abstract applying effects to any Roblox instance
@@ -54,7 +55,7 @@ end
5455
@return CFrame? -- Center of the bounding box
5556
@return Vector3? -- Size of the bounding box
5657
]=]
57-
function AdorneeUtils.getBoundingBox(adornee: Instance): (CFrame, Vector3)
58+
function AdorneeUtils.getBoundingBox(adornee: Instance): (CFrame?, Vector3?)
5859
if adornee:IsA("Model") then
5960
return adornee:GetBoundingBox()
6061
elseif adornee:IsA("Attachment") then
@@ -97,15 +98,15 @@ function AdorneeUtils.getParts(adornee: Instance): { BasePart }
9798
table.insert(parts, adornee)
9899
end
99100

100-
local searchParent
101+
local searchParent: Instance?
101102
if adornee:IsA("Humanoid") then
102103
searchParent = adornee.Parent
103104
else
104105
searchParent = adornee
105106
end
106107

107-
if searchParent then
108-
for _, part in pairs(searchParent:GetDescendants()) do
108+
if searchParent ~= nil then
109+
for _, part in searchParent:GetDescendants() do
109110
if part:IsA("BasePart") then
110111
table.insert(parts, part)
111112
end
@@ -183,7 +184,7 @@ function AdorneeUtils.getPartVelocity(adornee: Instance): Vector3?
183184
return nil
184185
end
185186

186-
return part.Velocity
187+
return part.AssemblyLinearVelocity
187188
end
188189

189190
--[=[
@@ -197,10 +198,11 @@ function AdorneeUtils.getPart(adornee: Instance): BasePart?
197198
if adornee:IsA("BasePart") then
198199
return adornee
199200
elseif adornee:IsA("Model") then
200-
if adornee.PrimaryPart then
201+
if adornee.PrimaryPart ~= nil then
201202
return adornee.PrimaryPart
202203
else
203-
return adornee:FindFirstChildWhichIsA("BasePart")
204+
local basePart: BasePart = adornee:FindFirstChildWhichIsA("BasePart")
205+
return basePart
204206
end
205207
elseif adornee:IsA("Attachment") then
206208
return adornee:FindFirstAncestorWhichIsA("BasePart")
@@ -237,7 +239,8 @@ function AdorneeUtils.getRenderAdornee(adornee: Instance): Instance?
237239
elseif adornee:IsA("Humanoid") then
238240
return adornee.Parent
239241
elseif adornee:IsA("Accessory") or adornee:IsA("Clothing") then
240-
return adornee:FindFirstChildWhichIsA("BasePart")
242+
local basePart = adornee:FindFirstChildWhichIsA("BasePart")
243+
return basePart
241244
elseif adornee:IsA("Tool") then
242245
local handle = adornee:FindFirstChild("Handle")
243246
if handle and handle:IsA("BasePart") then

src/adorneevalue/src/Shared/AdorneeValue.lua

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ function AdorneeValue.new()
2727
self._adornee = ValueObject.new()
2828
self._maid:GiveTask(self._adornee)
2929

30-
31-
3230
return self
3331
end
3432

@@ -37,7 +35,7 @@ end
3735
3836
@return Instance | CFrame | Vector3 | nil
3937
]=]
40-
function AdorneeValue:GetAdornee()
38+
function AdorneeValue:GetAdornee(): (Instance | CFrame | Vector3)?
4139
return self._adornee.Value
4240
end
4341

@@ -79,10 +77,10 @@ end
7977

8078
function AdorneeValue:__newindex(index, value)
8179
if index == "Value" then
82-
assert(typeof(value) == "Instance"
83-
or typeof(value) == "Vector3"
84-
or typeof(value) == "CFrame"
85-
or value == nil, "Bad value")
80+
assert(
81+
typeof(value) == "Instance" or typeof(value) == "Vector3" or typeof(value) == "CFrame" or value == nil,
82+
"Bad value"
83+
)
8684

8785
self._adornee.Value = value
8886
elseif index == "_adornee" or index == "_maid" then
@@ -102,19 +100,19 @@ end
102100
@return Observable<CFrame | nil>
103101
]=]
104102
function AdorneeValue:ObserveBottomCFrame()
105-
return Blend.Computed(self._adornee, function(adornee)
103+
return Blend.Computed(self._adornee, function(adornee: Instance): CFrame?
106104
if typeof(adornee) == "CFrame" then
107105
return adornee
108106
elseif typeof(adornee) == "Vector3" then
109107
return CFrame.new(adornee)
110108
elseif typeof(adornee) == "Instance" then
111109
-- TODO: Nearest bounding box stuff.
112110
local bbCFrame, bbSize = AdorneeUtils.getBoundingBox(adornee)
113-
if not bbCFrame then
111+
if not bbCFrame or not bbSize then
114112
return nil
115113
end
116114

117-
return bbCFrame * CFrame.new(0, -bbSize.y/2, 0)
115+
return bbCFrame * CFrame.new(0, -bbSize.Y / 2, 0)
118116
elseif adornee then
119117
warn("Bad adornee")
120118
return nil
@@ -140,7 +138,7 @@ end
140138
141139
@return Vector3 | nil
142140
]=]
143-
function AdorneeValue:GetCenterPosition()
141+
function AdorneeValue:GetCenterPosition(): Vector3?
144142
local adornee = self._adornee.Value
145143

146144
if typeof(adornee) == "CFrame" then
@@ -174,7 +172,7 @@ end
174172
175173
@return number?
176174
]=]
177-
function AdorneeValue:GetRadius()
175+
function AdorneeValue:GetRadius(): number?
178176
local adornee = self._adornee.Value
179177

180178
if typeof(adornee) == "CFrame" then
@@ -184,11 +182,11 @@ function AdorneeValue:GetRadius()
184182
elseif typeof(adornee) == "Instance" then
185183
-- TODO: Nearest bounding box stuff.
186184
local bbCFrame, bbSize = AdorneeUtils.getBoundingBox(adornee)
187-
if not bbCFrame then
185+
if not bbCFrame or not bbSize then
188186
return nil
189187
end
190188

191-
return bbSize.magnitude/2
189+
return bbSize.Magnitude / 2
192190
elseif adornee then
193191
warn("Bad adornee")
194192
return nil
@@ -212,9 +210,10 @@ function AdorneeValue:ObservePositionTowards(observeTargetPosition, observeRadiu
212210
observeTargetPosition,
213211
self:ObserveCenterPosition(),
214212
observeRadius or self:ObserveRadius(),
215-
function(target, radius, center)
213+
function(target: Vector3, radius: number, center: Vector3)
216214
return self:_getPositionTowards(target, radius, center)
217-
end)
215+
end
216+
)
218217
end
219218

220219
--[=[
@@ -226,7 +225,7 @@ end
226225
@param center Vector3
227226
@return Vector3
228227
]=]
229-
function AdorneeValue:GetPositionTowards(target, radius, center)
228+
function AdorneeValue:GetPositionTowards(target: Vector3, radius: number, center: Vector3): Vector3?
230229
assert(typeof(target) == "Vector3", "Bad target")
231230

232231
center = center or self:GetCenterPosition()
@@ -235,13 +234,13 @@ function AdorneeValue:GetPositionTowards(target, radius, center)
235234
return self:_getPositionTowards(target, radius, center)
236235
end
237236

238-
function AdorneeValue:_getPositionTowards(target, radius, center)
237+
function AdorneeValue:_getPositionTowards(target: Vector3, radius: number, center: Vector3): Vector3?
239238
if not (radius and target and center) then
240239
return nil
241240
end
242241

243242
local offset = target - center
244-
if offset.magnitude == 0 then
243+
if offset.Magnitude == 0 then
245244
return nil
246245
end
247246

@@ -255,7 +254,7 @@ end
255254
@return Observable<Instance?>
256255
]=]
257256
function AdorneeValue:ObserveAttachmentParent()
258-
return Blend.Computed(self._adornee, function(adornee)
257+
return Blend.Computed(self._adornee, function(adornee): Instance?
259258
if typeof(adornee) == "Instance" then
260259
-- TODO: Nearest bounding box stuff.
261260
local part = AdorneeUtils.getPart(adornee)
@@ -286,7 +285,7 @@ end
286285
function AdorneeValue:RenderPositionAttachment(props)
287286
props = props or {}
288287

289-
local observeWorldPosition = props.WorldPosition or self:ObserveCenterPosition();
288+
local observeWorldPosition = props.WorldPosition or self:ObserveCenterPosition()
290289
local observeParentPart = self:ObserveAttachmentParent()
291290

292291
local observeCFrame = Blend.Computed(observeParentPart, observeWorldPosition, function(parentPart, position)
@@ -295,7 +294,7 @@ function AdorneeValue:RenderPositionAttachment(props)
295294
else
296295
return CFrame.new(0, 0, 0)
297296
end
298-
end);
297+
end)
299298

300299
return Blend.New "Attachment" {
301300
Name = props.Name or "AdorneeValueAttachment";

src/animations/src/Shared/AnimationPromiseUtils.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ local AnimationPromiseUtils = {}
1515
Promises that the track is finished
1616
1717
@param animationTrack AnimationTrack
18-
@param endMarkerName string | nil
18+
@param endMarkerName string?
1919
@return Promise
2020
]=]
21-
function AnimationPromiseUtils.promiseFinished(animationTrack, endMarkerName)
21+
function AnimationPromiseUtils.promiseFinished(animationTrack: AnimationTrack, endMarkerName: string?)
2222
assert(typeof(animationTrack) == "Instance", "Bad animationTrack")
2323
assert(type(endMarkerName) == "string" or endMarkerName == nil, "Bad endMarkerName")
2424
local promise = Promise.new()
@@ -52,7 +52,7 @@ end
5252
@param animationTrack AnimationTrack
5353
@return Promise
5454
]=]
55-
function AnimationPromiseUtils.promiseLoaded(animationTrack)
55+
function AnimationPromiseUtils.promiseLoaded(animationTrack: AnimationTrack)
5656
assert(typeof(animationTrack) == "Instance", "Bad animationTrack")
5757

5858
if animationTrack.Length > 0 then
@@ -97,7 +97,7 @@ end
9797
@param keyframeName string
9898
@return Promise
9999
]=]
100-
function AnimationPromiseUtils.promiseKeyframeReached(animationTrack, keyframeName)
100+
function AnimationPromiseUtils.promiseKeyframeReached(animationTrack: AnimationTrack, keyframeName: string)
101101
assert(typeof(animationTrack) == "Instance", "Bad animationTrack")
102102
assert(type(keyframeName) == "string", "Bad endMarkerName")
103103

0 commit comments

Comments
 (0)