Search code examples
angularsqlitenativescript

error TS2350: Only a void function can be called with the 'new' keyword


I am trying to implement SQLite db connection to my app.

I am using the below code in my "sqlite.service.ts" file

import { Injectable } from "@angular/core";
var Sqlite = require{"nativescript-sqlite"};

@Injectable()
export class DatabaseService {

    public getdbConnection() {
        return new Sqlite('Assets');
    }

    public closedbConnection() {
        new Sqlite('Assets')
            .then((db) => {
                db.close();
            })
    }
}

I have used the nativescript code sample "Groceries app using SQLite" as the basis of this code and that works without errors.

Can anyone offer advice?


Solution

  • It should be require("nativescript-sqlite") instead of require{"nativescript-sqlite"}.