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
In my project, I have an enum that is common between all my different generated files. Ideally pgtyped would be smart enough to detect this is the same enum in all files and place it in some kind common file, but this isn't supported so I want to have a workaround myself with a custom common.ts
So now it's no longer a relative import and the generated code works as expected. This workaround does come with some unfortunate trade-offs though:
It makes that your project build output contains a @src import, making it harder to compose with other libraries unless you add an extra compilation step to remove this @src from your build output with tsc-alias (or a more heavy-handed approach like webpack)
Change the relative path transformation of typesOverrides that start with .. Given this would be a breaking change and it's not clear this wouldn't introduce new issues instead, this may not be the right option
Mention the workaround I came up with in the docs for others that have the same constraints. It's not a great solution long-term though for the reasons mentioned
The text was updated successfully, but these errors were encountered:
Describe the bug
In my project, I have an enum that is common between all my different generated files. Ideally
pgtyped
would be smart enough to detect this is the same enum in all files and place it in some kindcommon
file, but this isn't supported so I want to have a workaround myself with a customcommon.ts
for reference, this is my enum in sql
Expected behavior
The generated code by `pgtyped becomes
Behavior seen
Paths that start with a
.
are turned into relative imports here, so instead the generated code becomesWhich gives an error since this path doesn't exist
Workaround
As a workaround to this, I modified my tsconfig to use
and then updated my pgtyped config to be
So now it's no longer a relative import and the generated code works as expected. This workaround does come with some unfortunate trade-offs though:
@src
import, making it harder to compose with other libraries unless you add an extra compilation step to remove this@src
from your build output with tsc-alias (or a more heavy-handed approach like webpack)import * from './foo.queries'
#565Fixes
Given the context, I see 3 ways to solve this issue:
import * from './foo.queries'
#565)typesOverrides
that start with.
. Given this would be a breaking change and it's not clear this wouldn't introduce new issues instead, this may not be the right optionThe text was updated successfully, but these errors were encountered: