porsager / porsager/postgres

The type passed into the generic shouldn't have to be specified as an array

Open
#647 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted Typescript
Dominant language
JavaScript
Stars
8.7k
Forks
374
Avg merge
11d 16h
Merged PRs (30d)
1

Description

Currently using the library you would pass your type as such

type User = {
  email: string
  password: string
}

const [user] = await sql<U͟s͟e͟r[]>`
  SELECT * FROM example;
`;

console.log(user.email);

Though its not a huge deal I feel as code quality would be better with simply omitting it

type User = {
  email: string
  password: string
}

const [user] = await sql<U͟s͟e͟r>`
  SELECT * FROM example;
`;

console.log(user.email);

You can even see an example of this on the typescript documentation

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the TypeScript type definitions for the sql tagged-template API and compare how its generic parameter is currently interpreted. Verify whether sql can represent the returned row type without requiring an array, while preserving the documented destructuring example; the issue's TypeScript generics reference provides context for the intended syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, typescript
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.