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

TypeScript regression: loadOne no longer inferring types #2093

Closed
benjie opened this issue Jun 14, 2024 · 1 comment · Fixed by #2095
Closed

TypeScript regression: loadOne no longer inferring types #2093

benjie opened this issue Jun 14, 2024 · 1 comment · Fixed by #2095
Labels

Comments

@benjie
Copy link
Member

benjie commented Jun 14, 2024

See: https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgYwgOxgUwB4wDRwA2EAhgCYDyamBhwAzvAL5wBmUEIcARAOZQlWJRtwDcAKFCRYiOAHVgMABYAFXgGE6mDHBbtOPAAJkSMEmEIk0AejC8x48WUzJLUTHF7EARiUKJxODhrazhMejoMAFoyBhJvQkwo6lwoyI9DGABPMHDkKGAwGCjwyJhrNAhkkhBwsBJkTEC4NBq6ho8AcQEhRgCgoOAMTCghRrh1dCxcfoGgjggYNU1gbRgALnlFVQ0tDAk5pmajo-FUND7kGGw4AF4UKZwYAAoASglzvoX4e6vsADpeJgXtxvss9jBuO9gqEAILIRr0egAZSwYAAPAplODVhgAHxndB9AAkWD692I5ComGedEYzwA2t8ALqvAhoACuhEI7K5PLgwiyaGQcGeECK9Fedzxs1Y0FFn3g4qVrDgyslsyCITmAwAegB+ZpBRVwMG7XE-NVFBkABmZBwG2r1hqCR3mwI5UDQcAZ9vETHe4iAA

Reported by @purge

import { context, loadOne, list } from "grafast";
import { WithPgClient } from "@dataplan/pg";

declare global {
  // eslint-disable-next-line @typescript-eslint/no-namespace
  namespace Grafast {
    interface Context {
      rootPgClient: WithPgClient;
    }
  }
}

const ctx = context();
const root = ctx.get("rootPgClient"); // AccessStep<WithPgClient>
const $test = loadOne(list([root]), async (opts) => {
  for (const opt of opts) {
    //       ^? opt: unknown < Should be `UnwrapPlanTuple<...>`
    const rootPgClient = opt[0];
    //    ^? rootPgClient: any < Should be WithPgClient
  }
  return [];
});
@benjie
Copy link
Member Author

benjie commented Jun 14, 2024

(This was working fine in previous releases of Grafast, in particular beta.8 I think worked.)

purge added a commit to purge/postgraphile that referenced this issue Jun 15, 2024
- add types-test using tsd
- ensure types required in exported interfaces are not @internal
purge added a commit to purge/postgraphile that referenced this issue Jun 15, 2024
- add types-test using tsafe
- ensure types required in exported interfaces are not @internal
@benjie benjie closed this as completed in 7c92cb9 Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant