You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, this will fail if two or more of these files contain the same type definition. Notably, if for example both contain export type numberArray = (number)[]; then you will get the error
src/index.ts:3:1 - error TS2308: Module './select.queries.js' has already exported a member named 'numberArray'. Consider explicitly re-exporting to resolve the ambiguity.
Describe the solution you'd like
All extra type definitions created by pgtyped such as numberArray and other intermediary types (like enum types) should be places in a single common.ts (or a different name) and shared between all generated files. This doesn't introduce any performance overhead because these are all imported using import type which disappears at compile-time (and shouldn't negatively affect tree shaking either for the same reason).
Workaround
You can update your typesOverrides to alias common types to a common.ts manually:
Is your feature request related to a problem? Please describe.
Ideally in the
index.ts
for my project I can just doHowever, this will fail if two or more of these files contain the same type definition. Notably, if for example both contain
export type numberArray = (number)[];
then you will get the errorDescribe the solution you'd like
All extra type definitions created by
pgtyped
such asnumberArray
and other intermediary types (like enum types) should be places in a singlecommon.ts
(or a different name) and shared between all generated files. This doesn't introduce any performance overhead because these are all imported usingimport type
which disappears at compile-time (and shouldn't negatively affect tree shaking either for the same reason).Workaround
You can update your
typesOverrides
to alias common types to acommon.ts
manually:This workaround does come with some unfortunate tradeoffs:
common.ts
up-to-date if the SQL enum ever gets changed@src
import (see typesOverrides converts relative paths in possibly undesirable ways #564 for why)pgtyped
likenumberArray
that can't be aliased this way.The text was updated successfully, but these errors were encountered: