mirror of
https://github.com/littensy/charm.git
synced 2026-10-20 17:51:37 +00:00
fix: resolve type errors for new luau version
Some checks are pending
CI / analyze (push) Waiting to run
Some checks are pending
CI / analyze (push) Waiting to run
This commit is contained in:
parent
b05f3a9de6
commit
73fbfb2685
6 changed files with 13 additions and 13 deletions
|
|
@ -39,10 +39,10 @@ local syncCallback: ((client: any, payloads: { SyncPayload }) -> ())?
|
||||||
support custom implementations of reactive proxies.
|
support custom implementations of reactive proxies.
|
||||||
]]
|
]]
|
||||||
local function toRaw<T>(value: T): T
|
local function toRaw<T>(value: T): T
|
||||||
value = value :: types.ReactiveProxy<T>
|
local proxy = value :: types.ReactiveProxy<T>
|
||||||
if type(value) == "table" and type(value.__target) == "table" and type(value.__track) == "function" then
|
if type(proxy) == "table" and type(proxy.__target) == "table" and type(proxy.__track) == "function" then
|
||||||
value.__track()
|
proxy.__track()
|
||||||
return toRaw(value.__target)
|
return toRaw(proxy.__target)
|
||||||
end
|
end
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ test("should flatten functions", function()
|
||||||
local input = {
|
local input = {
|
||||||
a = Charm.atom(0),
|
a = Charm.atom(0),
|
||||||
b = { c = Charm.atom(0) },
|
b = { c = Charm.atom(0) },
|
||||||
d = { e = { f = utils.signalToAtom(Charm.signal(0)) } },
|
d = { e = { f = utils.signalToAtom<<number>>(Charm.signal(0)) } },
|
||||||
}
|
}
|
||||||
|
|
||||||
local result = utils.flatten<<{ [string]: Charm.Atom<number> }>>(input)
|
local result = utils.flatten<<{ [string]: Charm.Atom<number> }>>(input)
|
||||||
|
|
|
||||||
|
|
@ -486,7 +486,7 @@ local function signal<T>(initialValue: T, equals: Equals<T>?): (Getter<T>, Sette
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if the new value is different from the pending value
|
-- Check if the new value is different from the pending value
|
||||||
if if equals then not equals(node.pendingValue, value) else node.pendingValue ~= value then
|
if if equals then not equals(node.pendingValue, value :: T) else node.pendingValue ~= value then
|
||||||
if flags.frozen then
|
if flags.frozen then
|
||||||
deepFreeze(value)
|
deepFreeze(value)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,9 @@ end
|
||||||
]]
|
]]
|
||||||
local function toRaw<T>(value: T): T
|
local function toRaw<T>(value: T): T
|
||||||
if isReactive(value) then
|
if isReactive(value) then
|
||||||
value = value :: ReactiveProxy<T>
|
local proxy = value :: ReactiveProxy<T>
|
||||||
value.__track()
|
proxy.__track()
|
||||||
return toRaw(value.__target)
|
return toRaw(proxy.__target)
|
||||||
end
|
end
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
|
@ -115,7 +115,7 @@ end
|
||||||
@return A reactive proxy if the value is a table
|
@return A reactive proxy if the value is a table
|
||||||
]]
|
]]
|
||||||
local function toReactive<T>(value: T, trackParent: (() -> ())?): T
|
local function toReactive<T>(value: T, trackParent: (() -> ())?): T
|
||||||
return if type(value) == "table" then reactive(value, trackParent) else value
|
return if type(value) == "table" then reactive(value, trackParent) :: T else value :: T
|
||||||
end
|
end
|
||||||
|
|
||||||
function ReactiveProxy.__index(self: ReactiveProxy, key: any): any
|
function ReactiveProxy.__index(self: ReactiveProxy, key: any): any
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ local React = require("./React")
|
||||||
@return The current state.
|
@return The current state.
|
||||||
]]
|
]]
|
||||||
local function useSignalState<T>(getter: () -> T, dependencies: {}?): T
|
local function useSignalState<T>(getter: () -> T, dependencies: {}?): T
|
||||||
local value, setValue = React.useState(getter)
|
local value: T, setValue = React.useState(getter)
|
||||||
|
|
||||||
React.useLayoutEffect(function(): () -> ()
|
React.useLayoutEffect(function(): () -> ()
|
||||||
return Charm.listen(getter, setValue :: (T, T?) -> ())
|
return Charm.listen(getter, setValue :: (T, T?) -> ())
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[tools]
|
[tools]
|
||||||
wally = "UpliftGames/wally@0.3.2"
|
wally = "UpliftGames/wally@0.3.2"
|
||||||
rojo = "rojo-rbx/rojo@7.7.0-rc.1"
|
rojo = "rojo-rbx/rojo@7.7.0"
|
||||||
stylua = "johnnymorganz/stylua@2.5.2"
|
stylua = "johnnymorganz/stylua@2.5.2"
|
||||||
luau-lsp = "johnnymorganz/luau-lsp@1.68.1"
|
luau-lsp = "johnnymorganz/luau-lsp@1.70.1"
|
||||||
lute = "luau-lang/lute@1.0.0"
|
lute = "luau-lang/lute@1.0.0"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue