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

Incorrect TypeScript definition for addConstraint #1154

Closed
pigulla opened this issue May 6, 2024 · 0 comments · Fixed by #1155
Closed

Incorrect TypeScript definition for addConstraint #1154

pigulla opened this issue May 6, 2024 · 0 comments · Fixed by #1155
Assignees
Labels
c: bug Something isn't working p: 1-normal Nothing urgent
Milestone

Comments

@pigulla
Copy link
Contributor

pigulla commented May 6, 2024

Describe the bug

When calling addConstraint, using an object as the second parameter causes a TypeScript error:

TS2345: Argument of type '{ check: string; }' is not assignable to parameter of type 'string'.

This was presumably introduced in #1129 when a union type seems to have been accidentally refactored into an intersection type (diff).

Steps to reproduce

Create a TypeScript migration:

import { type MigrationBuilder } from 'node-pg-migrate';

export function up(pgm: MigrationBuilder): void {
  pgm.createTable('my_table', {
    my_column: {
      type: 'VARCHAR(255)',
    },
  });
  pgm.createConstraint('my_table', 'my_column', {
    check: 'my_column IS NOT NULL'
  });
}

Logs

No response

System Info

System:
  OS: Linux 5.10 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
  CPU: (6) arm64 unknown
  Memory: 5.02 GB / 15.61 GB
  Container: Yes
  Shell: 5.8 - /usr/bin/zsh
Binaries:
  Node: 18.20.2 - ~/n/bin/node
  npm: 10.5.0 - ~/n/bin/npm

Used Module System

cjs

@pigulla pigulla added the s: pending triage Pending Triage label May 6, 2024
pigulla added a commit to pigulla/node-pg-migrate that referenced this issue May 6, 2024
pigulla added a commit to pigulla/node-pg-migrate that referenced this issue May 6, 2024
@Shinigami92 Shinigami92 added c: bug Something isn't working p: 1-normal Nothing urgent and removed s: pending triage Pending Triage labels May 6, 2024
@Shinigami92 Shinigami92 added this to the v7.x milestone May 6, 2024
pigulla added a commit to pigulla/node-pg-migrate that referenced this issue May 6, 2024
pigulla added a commit to pigulla/node-pg-migrate that referenced this issue May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants