Missing methods from `SetIterator<T>` · Issue #1600 · TypeScriptToLua/TypeScriptToLua · GitHub
Skip to content

Missing methods from SetIterator<T> #1600

Open

Description

@musjj
const a = ["foo", "bar"];
a.every((v) => typeof v === "string");

const b = new Set(["foo", "bar"]);
const values = b.values().toArray();
values.every((v) => typeof v === "string");

const c = new Set(["foo", "bar"]);
c.values().every((v) => typeof v === "string");

The code compiles to:

local ____lualib = require("lualib_bundle")
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local a = {"foo", "bar"}
__TS__ArrayEvery(
    a,
    function(____, v) return type(v) == "string" end
)
local b = __TS__New(Set, {"foo", "bar"})
local values = b:values():toArray()
__TS__ArrayEvery(
    values,
    function(____, v) return type(v) == "string" end
)
local c = __TS__New(Set, {"foo", "bar"})
c:values():every(function(____, v) return type(v) == "string" end)
return ____exports

Here, :toArray() and :every() is missing from the set iterator returned by :values(), causing a runtime error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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