-
-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
Describe the bug
The generated dts file may contains redundant empty lines.
Generated dist/migrator.d.ts
import { SchemaUpdater } from "./types.d-CKogjk-3.js";
import { Migration, MigrationProvider, MigratorProps } from "kysely";
//#region src/migrator/code-provider.d.ts
/**
* Create provider inside code
* @param migrations kysely migration, support Record or Array
* @param idLength index id length, default is 8
* @example
* ```ts
* import { createCodeProvider, useMigrator } from 'kysely-sqlite-builder/migrator'
*
* const provider = createCodeProvider({
* '2024-01-01': {
* up: async (db) => {
* await db.schema.createTable('test').ifNotExists().column('name', 'text').execute()
* }
* },
* '2024-01-02': {
* up: async (db) => {
* await db.schema.alterTable('test').addColumn('age', 'integer').execute()
* },
* down: async (db) => {
* await db.schema.alterTable('test').dropColumn('age').execute()
* }
* }
* })
* await db.syncDB(useMigrator(provider, options))
*
* // or use array
* const providerArray = createCodeProvider([
* {
* up: async (db) => {
* await db.schema.createTable('test').ifNotExists().column('name', 'text').execute()
* }
* },
* {
* up: async (db) => {
* await db.schema.alterTable('test').addColumn('age', 'integer').execute()
* },
* down: async (db) => {
* await db.schema.alterTable('test').dropColumn('age').execute()
* }
* }
* ])
* await db.syncDB(useMigrator(providerArray, options))
* ```
*/
declare function createCodeProvider(migrations: Record<string, Migration> | Migration[], idLength?: number): MigrationProvider;
//#endregion
//#region src/migrator/index.d.ts
/**
* Use migrator to migrate to latest
* @param provider migration provider
* @param options migrator options
*/
declare function useMigrator(provider: MigrationProvider, options?: Omit<MigratorProps, "db" | "provider">): SchemaUpdater;
//#endregion
export { createCodeProvider, useMigrator };
Fixed by modify this line
rolldown-plugin-dts/src/generate.ts
Line 233 in 7c8b361
code: dtsMap.get(id)!.code, |
to
code: dtsMap.get(id).code.split('\n').filter(l => l.trim().length).join('\n')
Reproduction
subframe7536/kysely-sqlite-builder#4
System Info
Windows 11
Used Package Manager
bun
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- The provided reproduction is a minimal reproducible of the bug.
Metadata
Metadata
Assignees
Labels
No labels