Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix TypeScript migration stub after 0.95.0 changes #4366

Merged
merged 2 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/migrations/migrate/stub/ts.stub
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as Knex from "knex";
import { Knex } from "knex";

<% if (d.tableName) { %>
export async function up(knex: Knex): Promise<Knex.SchemaBuilder> {
return knex.schema.createTable("<%= d.tableName %>", (t: Knex.AlterTableBuilder) => {
return knex.schema.createTable("<%= d.tableName %>", (t) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why Knex.AlterTableBuilder was removed? Is it redundant now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's redundant, TypeScript infers the type which is actually Knex.CreateTableBuilder not Knex.AlterTableBuilder.

t.increments();
t.timestamps();
});
Expand Down
2 changes: 2 additions & 0 deletions test-tsd/types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ expectType<any>(knexCjs({}));
// eslint-disable-next-line
expectType<any>(knexCjsNamed({}));

knex({}).schema.createTable("table", (t: Knex.AlterTableBuilder) => {})

const knexInstance = knexDefault(clientConfig);

// ToDo remove this copy-pasted type after we can export it as a named properly
Expand Down