Skip to content

Conversation

@maxcbc
Copy link
Contributor

@maxcbc maxcbc commented Oct 2, 2025

TransactionSql is missing properties from Sql added in

postgres/src/index.js

Lines 69 to 82 in 32feb25

Object.assign(sql, {
get parameters() { return options.parameters },
largeObject: largeObject.bind(null, sql),
subscribe,
CLOSE,
END: CLOSE,
PostgresError,
options,
reserve,
listen,
begin,
close,
end
})
.

This PR updates the type definition of TransactionSql to reflect this.

This means typescript will now raise an error if consuming code tries the following:

sql.begin((trx) => {
   trx.begin((trx2) => {
       ...
   })
})

@porsager porsager force-pushed the master branch 2 times, most recently from 4a0fe34 to 3a43815 Compare November 12, 2025 04:40
@porsager porsager merged commit 36a53f6 into porsager:master Nov 12, 2025
@porsager
Copy link
Owner

Thx :) Not into typescript, but looks about right 😅

@stephenh
Copy link
Contributor

stephenh commented Dec 30, 2025

@porsager / @maxcbc this caused a pretty serious regression, i.e. all sql calls within sql.begins are now broken:

sql.begin(async (sql) => {
  await sql`my query`; // <== error here:
  // TS2349: This expression is not callable.
  // Type TransactionSql<{}> has no call signatures.
});

See Dimous's comment here:

36a53f6#commitcomment-170665877

@maxcbc do you mind either preparing a revert, or fixing forward?

...also I'm kinda curious, @maxcbc how did this regression not show up in your codebase? Afaict like every sql`` within a sql.begin is broken for me.

@porsager I get you personally do not like TypeScript, but some amount of type checking-as-unit-tests in the postgres.js build/release process would likely be a good idea, otherwise folks maintaining these types are just guessing about what will/will not fix/improve/regress the types.

@AntonOfTheWoods
Copy link

AntonOfTheWoods commented Jan 7, 2026

So @porsager even though this probably broke the code of every typescript user of this library and the issue was raised well before releasing the new version - "I don't like typescript"?

@porsager
Copy link
Owner

porsager commented Jan 7, 2026

Tell me if there's a PR or make one, and I'll merge and make a release.

@sep2
Copy link

sep2 commented Jan 7, 2026

@porsager PR #1144
tested locally did not break anything.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants