that is a really great update but can be there a way that automatically (i donot know how to say it so i will just send an image)
Ive been waiting for these features patiently
Im so excited to try them out!
Hello. In my module, I have a dictionary which I store messages in, and I have another module that uses this module’s dictionary to access specific messages. But after I enabled the new type solver, It now produces a warning that says: “Cannot add indexer to table.” How can I solve this warning?
We’d like to have bounded generics completed before the full release of the new type solver, but I’m unsure of exactly what order things will be implemented in, or how long it will take to get things into shape for the full release. Likewise for write-only properties, they’re planned for the full release, but I don’t know when they’ll be done.
Not blocked-4378
! Aggghhh!
There also seems to be a strict-mode inference problem with closures:
--!strict
local A
A = 1
local Value = A + 2 -- fine, is number
local function B(): number
return A + 3 -- not fine, is number?
end
Anyways, very excited for how this turns out! It definitely feels more stricter, although I’ll probably have to go over some code to make sure everything works properly.
I have to re-write my module from ground up with the new type system and it’s not even supporting many things I’m trying to do lol.
This is so ducking amazing, I LOVE ITTTTTTTTTTTTTTTT
Horrifying sight, especially in a game that had 0 before.
Jokes aside, I do not understand this type error.
That’s the only place
indice
is used.
Try running a for loop with a table, now it requires an indexer to loop through it for some reason.
Do we have to use the index
in order to do a for loop?
I had problems with indexing from a type of {}
, because that correctly represents an empty table now, as opposed to an open one.
I just replaced the annotation to {unknown}
or {[unknown]: unknown}
and that solves it.
export type classData = {
constructor: (self: any, ...any) -> ()?,
destructor: (self: any) -> ()?,
Public: {[any]: any}?,
Private: {[any]: any}?,
Protected: {[any]: any}?,
Friend: {any}?
}
I have a table type like this, so I can’t exactly cast unknown to it, what should I do in this case?
I’m assuming the solver isn’t adding an indexer type-function to record table types, which is why you can’t iterate over your classData
directly.
Band-aid solution would be to ascribe before iterating:
for Key, Value in Record :: {[string]: unknown} do
end
Otherwise, why can’t you just index the fields individually?
That’s what I did for now, but this solution is pretty much what I used to do in the old type solver, I thought these problems would get solved in the new one.
Is this intended behaviour or is it a bug with the new type solver?
Try using this:
key: index<typeof(PlayerData), keyof<typeof(PlayerData)>>
This is exactly the step forward Luau needs! It feels like it addresses some of the bigger practical barriers to using strict mode + type safety that currently exist. Great work to the whole team involved in designing and implementing these new features
Here’s a code with the blocked-xxxx… error
Code
--!strict
local con: RBXScriptConnection?
local timeElapsed = 0
con = game:GetService("RunService").PostSimulation:Connect(function(dt: number)
timeElapsed += dt
if timeElapsed >= 5 then
con:Disconnect() -- *blocked*: typecheck error occurs here
con = nil
end
end)
i was concerned about this being released too early, while i know this is a beta it just doesn’t feel ready yet however i feel like this’ll be leagues better than old solver once it’s resolved
i will probably adjust to try using the new solver since i was looking forward to keyof
and type functions but jesus christ that’s a lot of weird errors
Sounds great, but in my project turning this on just has the effect of disabling all linting/typechecking/intellisense globally. It’s not an issue in the template projects so I know it’s not my app configuration. Any idea why this might happen?