mmkal / pgkit

PostgreSQL🤝TypeScript monorepo. SQL client/admin UI/smart migrator/type generator/schema inspector

Home Page:https://pgkit.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

typeMapper only accepts globally available types

Ericnr opened this issue · comments

Currently I need to declare global types if I want to map postgres numeric type to a Decimal class exported by a lib. We could have an api like importTypes: 'process.cwd() + '/src/types/slonikTypes' so that file is imported by every type gen file.

@Ericnr you should be able to use import, something like:

setupTypeGen({
  knownTypes,
  typeMapper: {
    numeric: [`import('../types/slonikTypes').Decimal`, toDecimal],
  },
})

Edit: closing, but feel free to reply here if you think this should be reopened.