rockdai / sql-bricks

Transparent, Schemaless SQL Generation
http://csnw.github.io/sql-bricks
MIT License
213 stars 25 forks source link

Type definition problem #125

Open kayvaninvemo opened 3 years ago

kayvaninvemo commented 3 years ago

I am not sure how to get Type Definition file. Here is one type definition, which is not published on npm. And there is and inconsistent type definition in definitely typed repo.

In this repo

  interface DeleteStatement extends Statement {
    from(...tbls: string[]): DeleteStatement
    using(...columnList: string[]): DeleteStatement
    using(columnList: string[]): DeleteStatement
    where(column?: string | null, value?: any): DeleteStatement
    where(...whereExpr: WhereExpression[]): DeleteStatement
    and(column?: string | null, value?: any): DeleteStatement
    and(...whereExpr: WhereExpression[]): DeleteStatement
  }

here is the code from DefinitelyTyped

  interface DeleteStatement extends Statement {
    from(...tbls: string[]): DeleteStatement
    using(...columnList: string[]): SelectStatement
    using(columnList: string[]): SelectStatement
    where(column?: string | null, value?: any): SelectStatement
    where(...whereExpr: WhereExpression[]): SelectStatement
    and(column?: string | null, value?: any): SelectStatement
    and(...whereExpr: WhereExpression[]): SelectStatement
  }
prust commented 3 years ago

@kayvaninvemo:

I am not sure how to get Type Definition file. Here is one type definition, which is not published on npm

I think this is a duplicate of #122:

The typescript definitions were contributed (see #109) on master, which is a pre-release version (package.json currently says 3.0.0-beta.2 on master). v2.0.5 does not have typescript definitions.

IOW, if you reference 3.0.0-beta.2 from npm, then you should get the types.

This is not intuitive or ideal -- 3.x hasn't diverged very much from 2.x yet, so most (perhaps all) of the definitions are correct, but there are plans to diverge. If you would be willing to create a pull request with this file added, targeting the 2.x branch, I would merge it & publish as 2.0.6 (I don't use typescript myself, so I rely on contributors to test & maintain typescript support).

there is and inconsistent type definition in definitely typed repo

Yes, this looks wrong/out-of-date. I don't know the process for updating definitions in definitely-typed (I didn't add them, a contributor did -- it is independently managed); if you're interested, you're welcome to update the definitions there.