AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
6.98k stars 649 forks source link

Add Database interface to type definitions #1865

Closed rendall closed 6 months ago

rendall commented 6 months ago

This fixes issue #1180 and adds the property Database to the types/alasql.d.ts file.

The Getting Started section has this code:

    var mybase = new alasql.Database();
    mybase.exec('CREATE TABLE one (two INT)');

However, when using TypeScript, this causes a type error such as:

src/lib/utils.ts:239:25 - error TS2551: Property 'Database' does not exist on type 'AlaSQL'. Did you mean 'databases'?

239   const db = new alasql.Database();
                            ~~~~~~~~

The cause is that [types/alasql.d.ts] has no Database in its type definitions. This PR adds that type definition.

mathiasrw commented 6 months ago

Thank you!

Released as part of v4.2.6