Skip to content

Commit eb83794

Browse files
authored
Use DataModel analysis (#227)
For some reason, using `tests.project.json` gives better analysis that `dev.project.json`. Seems like this is because the former will mount flipbook to the DataModel. This PR updates our analysis to generate sourcemaps from `tests.project.json`, and also fixes up the resulting type errors from this change
1 parent bd8c58d commit eb83794

File tree

11 files changed

+20
-11
lines changed

11 files changed

+20
-11
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959

6060
- name: Generate sourcemap for LSP
6161
shell: bash
62-
run: rojo sourcemap dev.project.json -o sourcemap.json
62+
run: rojo sourcemap tests.project.json -o sourcemap.json
6363

6464
- name: Analyze
6565
shell: bash

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"luau-lsp.sourcemap.rojoProjectFile": "tests.project.json"
3+
}

bin/analyze.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
curl -s -O https://raw.githubusercontent.com/JohnnyMorganz/luau-lsp/master/scripts/globalTypes.d.lua
44

5-
rojo sourcemap dev.project.json -o sourcemap.json
5+
rojo sourcemap tests.project.json -o sourcemap.json
66

77
luau-lsp analyze --sourcemap=sourcemap.json --defs=globalTypes.d.lua --defs=testez.d.lua --ignore=**/_Index/** src/
88

src/Components/ComponentTree/Component/Directory.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Props = {
2121
local function Directory(props: Props)
2222
local theme = useTheme()
2323
local hover, setHover = React.useState(false)
24-
local styles = RoactSpring.useSpring({
24+
local styles = (RoactSpring.useSpring :: any)({
2525
alpha = if hover then 0 else 1,
2626
rotation = if props.expanded then 90 else 0,
2727
config = constants.SPRING_CONFIG,

src/Components/ComponentTree/Component/Story.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Props = {
2020
local function Story(props: Props)
2121
local theme = useTheme()
2222
local hover, setHover = React.useState(false)
23-
local styles = RoactSpring.useSpring({
23+
local styles = (RoactSpring.useSpring :: any)({
2424
alpha = if not props.active then if hover then 0 else 1 else 0,
2525
color = if not props.active then theme.divider else theme.selection,
2626
textColor = if not props.active then theme.textFaded else theme.background,

src/Components/DragHandle.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ local function DragHandle(props: Props)
2525
local plugin = React.useContext(PluginContext.Context)
2626
local isDragging, setIsDragging = React.useState(false)
2727
local isHovered, setIsHovered = React.useState(false)
28-
local mouseInput: InputObject, setMouseInput = React.useState(nil)
28+
local mouseInput, setMouseInput = React.useState(nil :: InputObject?)
2929

3030
local getHandleProperties = React.useCallback(function()
3131
local size: UDim2

src/Components/Navbar/Item.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ local function Item(props: Props)
1919
local theme = useTheme()
2020

2121
local hover, setHover = React.useState(false)
22-
local styles = RoactSpring.useSpring({
22+
local styles = (RoactSpring.useSpring :: any)({
2323
alpha = if not props.active and hover then 0 else 1,
2424
config = constants.SPRING_CONFIG,
2525
})

src/Components/ResizablePanel.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ local function ResizablePanel(props: Props)
3636
end, { absoluteSize })
3737

3838
local isWidthResizable = React.useMemo(function()
39-
return Sift.Array.includes(props.dragHandles, "Left") or Sift.Array.includes(props.dragHandles, "Right")
39+
if props.dragHandles then
40+
return Sift.Array.includes(props.dragHandles, "Left") or Sift.Array.includes(props.dragHandles, "Right")
41+
end
42+
return nil
4043
end, { props.dragHandles })
4144

4245
local isHeightResizable = React.useMemo(function()
43-
return Sift.Array.includes(props.dragHandles, "Top") or Sift.Array.includes(props.dragHandles, "Bottom")
46+
if props.dragHandles then
47+
return Sift.Array.includes(props.dragHandles, "Top") or Sift.Array.includes(props.dragHandles, "Bottom")
48+
end
49+
return nil
4450
end, { props.dragHandles })
4551

4652
local width = React.useMemo(function()

src/Components/Searchbar.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ local function Searchbar(props: Props)
3131
local isFocused, setIsFocused = React.useState(false)
3232
local isExpanded = isFocused or search ~= ""
3333

34-
local styles = RoactSpring.useSpring({
34+
local styles = (RoactSpring.useSpring :: any)({
3535
alpha = if isExpanded then 1 else 0,
3636
config = constants.SPRING_CONFIG,
3737
})

src/Components/StoryView.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ local function StoryView(props: Props)
3434
local extraControls, setExtraControls = React.useState({})
3535
local controlsHeight, setControlsHeight = React.useState(constants.CONTROLS_INITIAL_HEIGHT)
3636
local topbarHeight, setTopbarHeight = React.useState(0)
37-
local storyParentRef = React.useRef()
37+
local storyParentRef = React.useRef(nil :: GuiObject?)
3838
local controls
3939

4040
if story and story.controls then

0 commit comments

Comments
 (0)