Is your feature request related to a problem? Please describe.
Ideally in the index.ts for my project I can just do
export * from './select.queries.js';
export * from './insert.queries.js';
export * from './update.queries.js';
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 #564 for why)pgtyped
likenumberArray
that can't be aliased this way.