adelsz / pgtyped

pgTyped - Typesafe SQL in TypeScript
https://pgtyped.dev
MIT License
2.97k stars 97 forks source link

Support 'import type' syntax. #531

Closed antl3x closed 1 year ago

antl3x commented 1 year ago

Describe the bug I'm using "typesOverrides": {} options with typescript 5.0.0 and i'm receiving the following compile error on the *.queries.ts generated file:

This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'.ts(1371)

Since Typescript 3.8, the correct way is to use type-only imports and exports.

See: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export

Test case

The type override was imported using the following syntax:

import { SubscriptionStatus } from '../../../';

The correct way (since is only a type and not a value) is to use:

import type { SubscriptionStatus } from '../../../';

adelsz commented 1 year ago

Thanks, this makes sense. Fixed in https://github.com/adelsz/pgtyped/commit/72ba5bc4f03df02a9abe8f9f137d305c3e90751d