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

Error with types in Typescript file using the ES6 module format. #630

Closed
b4git opened this issue May 24, 2021 · 5 comments
Closed

Error with types in Typescript file using the ES6 module format. #630

b4git opened this issue May 24, 2021 · 5 comments

Comments

@b4git
Copy link

b4git commented May 24, 2021

Code (Link to Playground):

import Database from "better-sqlite3";

class DBTester {
db: BetterSqlite3.Database;

  constructor() {
    this.db = new Database(":memory:");
  }
}
new DBTester();

Error:

Cannot find namespace 'BetterSqlite3'.ts(2503)
Public property 'db' of exported class has or is using private name 'BetterSqlite3'.ts(4031)
@Prinzhorn
Copy link
Contributor

Prinzhorn commented May 25, 2021

Possible duplicate of #423 since there is currently no officical TypeScript support. Also DefinitelyTyped/DefinitelyTyped#52163 in case you are using that package.

@tim-rohrer
Copy link

@b4git, did you arrive at a solution for this?

@CanRau
Copy link

CanRau commented Jul 9, 2022

For reference, this should work

or alternative

also make sure to install @types/better-sqlite3

@tim-rohrer
Copy link

Thanks @CanRau.

I believe I ended up getting this to work:

Import DatabaseConstructor, { Database } from “better-sqlite3”

let db: Database

db = new DatabaseConstructor(:memory:)

I do not remember particulars so….

@CanRau
Copy link

CanRau commented Jul 9, 2022

Aah yea nice 👌 only thing if I recall correctly that's needing some tsconfig to support default imports which are kinda non-standard in TS if I'm not mistaken.

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

No branches or pull requests

5 participants