selene
selene copied to clipboard
Feature request: add support for detecting invalid types
Correct me if I am wrong, but it seems like every type is allowed. This code
local partInformationItem: nonsense = PartInformation:new(part)
is allowed, eventhough 'nonsense' is not a defined and valid type.
selene parses typed syntax, but completely ignores them in all lints. This is because creating a real type checker, or even just any form of type inference, is a hugely complicated problem that is far out of scope for selene.
That being said, I warily deem this within scope, since no inference or knowledge of types is actually required here. However, it is not totally trivial:
- The
robloxstandard library, or some external source, is going to have to keep a list of all possible types, to support natives. - It will be unable to tell anything through imports, as selene is per file. This means that if you do
local thing: Something.nonsense, selene will not attempt to see if it is wrong, assuming Something is a declared variable and not a native type. - If there's any way to get a global type without requiring it (such as a
.d.tsfile), then this lint can't exist, as it will not be feasible for selene to get that information, and selene, as a general rule, can never be wrong.