Johan Grundberg
Johan Grundberg
KKysely
Created by Johan Grundberg on 5/6/2024 in #help
Type-only imports in migration files
In the Kysely documentation, an example is given of a migration file which imports Kysely from the kysely package. This import is only used to type the up and down functions, but not as a value. Depending on the TypeScript verbatimModuleSyntax compiler option, this may or may not result in a runtime import in the compiled code, which in the worst case could mean different behaviors of the migration script. My question is: Is it safe to import Kysely with a type-only import in migration files? If not, what side effects of the import are needed in such files? If the idea (as I suspect) is indeed only to import the Kysely type for typing the function arguments, I suggest also that the example should be changed to use a type-only import or accompanied by a note about the possibility of such an import.
6 replies