Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS crash on some cyclic thunks #1072

Open
ssalbdivad opened this issue Aug 2, 2024 · 0 comments
Open

TS crash on some cyclic thunks #1072

ssalbdivad opened this issue Aug 2, 2024 · 0 comments

Comments

@ssalbdivad
Copy link
Member

With the changes made following 2.0.0-beta.2, the following type now leads to a TS crash:

const $ = scope({
  filename: "0<string<255",
  file: {
    type: "'file'",
    name: "filename",
  },
  directory: {
    type: "'directory'",
    name: "filename",
    children: () =>
      $.type("root[]").narrow((v, ctx) => {
        if (new Set(v.map((f) => f.name)).size !== v.length)
          return ctx.mustBe("names must be unique in a directory");

        return true;
      }),
  },
  root: "file|directory",
});

const types = $.export();

The equivalent type with a thunk implementation is fine, but it would be good to know the exact change/trade off that led to a problem with this kind of cyclic thunk, and perhaps log an issue with the Ts team for the crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant