--!strict
type Value<T> = {
kind: "value",
value: T
}
local function peekA<T>(state: Value<T> | T): T
if typeof(state) == "table" and state.kind == "value" then -- OK
return (state :: Value<T>).value :: T
else
return state :: T
end
end
local function peekB<T>(state: Value<T> | T): T
return if typeof(state) == "table" and state.kind == "value" -- TypeError: Key 'kind' is missing from 'T & table' in the type '(T & table) | Value<T>' Luau(1032)
then (state :: Value<T>).value :: T
else state :: T
end
Tested with Luau 0.689 release (new solver).