Skip to content

Buggy enum transpilation with namespace #1677

@felixhirt

Description

@felixhirt

This Input:
namespace What {
export enum Is {
Going,
On
}
}
Transpiles to:
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
What = What or ({})
do
What.Is = Is or ({})
What.Is.Going = 0
What.Is[What.Is.Going] = "Going"
What.Is.On = 1
What.Is[What.Is.On] = "On"
end

Two points:

  • Why the bidirectional enum handling by default? What if someone wants to take advantage of lua's simplicity and iterates over it with "pairs"? I just learned that numeric typescript enums are bidirectional...
  • Why "What.Is = Is or ({})" ?? Should it not be "What.Is = What.Is or ({})"

See: https://typescripttolua.github.io/play/#code/5.4/PTA2FMBcAIEkGdoF5oCIByB7A4pzATVAKADsBDAW3HgAcyBjcaAdQAsyYBvI6acADxqYATjHAkArhTiJuvXrgCWJAOYAaHvIDyJTQF8iBgGYjoACggwA2gGs1ANwC60TEeh1Fw+GbYcAdAgAlIFy7sLKkGZ29oGGQA

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions