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

TableBuilder type is missing some members #3853

Open
mprast opened this issue May 14, 2020 · 2 comments
Open

TableBuilder type is missing some members #3853

mprast opened this issue May 14, 2020 · 2 comments

Comments

@mprast
Copy link

mprast commented May 14, 2020

Environment

Knex version: 0.21.1
Database + version: mysql 8.0.20
OS: Fedora 30

@lorefnon

Bug

  1. Explain what kind of behaviour you are getting and how you think it should do
const builder: knex.AlterTableBuilder = <get table builder>;

builder.datetime("colA");
builder.double("colB");

^^this should compile (i.e. it runs fine in plain javascript) but it produces a type error. Same thing happens for CreateTableBuilder

  1. Error message

Property 'datetime' does not exist on type AlterTableBuilder

and

Property 'double' does not exist on type AlterTableBuilder

  1. Reduced test code, for example in https://npm.runkit.com/knex or if it needs real
    database connection to MySQL or PostgreSQL, then single file example which initializes
    needed data and demonstrates the problem.

See above. You can also see it by inspecting the type.

Worth noting that while it appears double is still undocumented, datetime is in the docs and is not camel-cased in the example like it is in the type.

Thanks for taking a look!

@FreedomBen
Copy link

There are types missing from SchemaBuilder as well. Having a compile error with knex.schema.createExtensionIfNotExists('uuid-ossp')

Grepping the source it looks like the method is there in lib/schema/builder.js but the type definition isn't present in types/index.d.ts. This is my second day with TypeScript so I don't know how to fix it, but I would if I could.

Happy to open a new issue if it's helpful.

Oh also knexjs.org doesn't have the "ifNotExists" versions of various methods documented. I found them with Google luck.

@C0Nd3Mnd
Copy link
Contributor

I would assume that datetime doesn't exist in the definition file because the alias dateTime does (and is probably preferred?). Not sure about double though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants