Hello fellow developers,
Is it possible to have generics but for the type names instead of the types?
I have a clan type and when users of my module change the defaultRank
, that name should be shown at autocompletion automatically (and it shouldn’t warn me in strict mode that I have an extra field).
--!strict
local defaultRank = "Member"
type rank = {[number]:number}
type clan = {
defaultRank: rank, --defaultRank should be Member
Leader: number
}
Workaround
local defaultRank = "Member"
type defaultRank = {Member: rank} --you have to change two things
type clan = {
Leader: number
} & defaultRank
Honestly I don’t think this is achievable as of writing, but maybe you guys have a solution!