react-native-sqlite-storage icon indicating copy to clipboard operation
react-native-sqlite-storage copied to clipboard

Typescript Definition File?

Open MartinWebDev opened this issue 8 years ago • 13 comments

Hi, sorry to bother you, and I know this isn't an "issue" as such. But is there a Typescript Definition file I can download somewhere for this package? I am trying to write my own as I go and just add whatever functions and return types I need as I find them, but I've not got much experience in writing d.ts files so if someone already has one I would really appreciate a copy.

Perhaps one could be added into the repo?

Thanks :)

MartinWebDev avatar Jul 12 '17 15:07 MartinWebDev

No Typescript Definition File yet I am afraid.

andpor avatar Jul 13 '17 17:07 andpor

hmm, I guess I have one somewhere. Will try to take a time to find it and add :)

dryganets avatar Aug 15 '17 01:08 dryganets

Hey @dryganets, quite a few months ago you mentioned about a type definition file for this, but is not available (or I can't find it)

Is it going to be produced?

rodrigoelp avatar Dec 19 '17 03:12 rodrigoelp

By the way, it would be great to get the type definition file. I have created a couple of other projects and I've started to read your tests (index.ios.promise.js) and I honestly don't know where to start with your code :(

rodrigoelp avatar Dec 19 '17 03:12 rodrigoelp

@rodrigoelp PR for TypeScript would be welcome. I don't know where to start either but hope you can figure it out.

andpor avatar Dec 19 '17 09:12 andpor

Hi @andpor, I've started to look into it and have created the basic shape of the react-native-sqlite-storage module. I do need to check with you a few function names as I have been following your tests to create the definition.

The plugin as such as: DEBUG, enablePromise, openDatabase and deleteDatabase, right?

Then the database as such should be: executeSql, transaction and close.

All these definitions have a callback and promise flavour.

Am I missing something else?

rodrigoelp avatar Dec 19 '17 10:12 rodrigoelp

these are the functions of the database - you need an instance

[false,"SQLitePlugin","transaction",false,true,true], [false,"SQLitePlugin","readTransaction",false,true,true], [false,"SQLitePlugin","close",false,false,true], [false,"SQLitePlugin","executeSql",true,false,true], [false,"SQLitePlugin","sqlBatch",false,false,true], [false,"SQLitePlugin","attach",true,false,true], [false,"SQLitePlugin","detach",false,false,true], [false,"SQLitePluginTransaction","executeSql",true,false,false],

These are database factory methods: [false,"SQLiteFactory","deleteDatabase",false,false,true], [true, "SQLiteFactory","openDatabase",false,false,true], [false,"SQLiteFactory","echoTest",false,false,true]

Depending on the interface choice these work in a callback or promise fashion.

DEBUG and enablePromise are utility functions that related to the module rather than the db itsef.

andpor avatar Dec 19 '17 16:12 andpor

Guys it looks like @matrosov-nikita contributed a nice set of typings for DefinitelyTyped in https://github.com/litehelpers/Cordova-sqlite-storage/pull/657 and I am thinking to integrate into the cordova-sqlite-storage plugin project that this project was based on. It may be ideal to share the typings between the different sqlite plugin versions as much as possible.

If you would like to see something different from the typings proposed in https://github.com/litehelpers/Cordova-sqlite-storage/pull/657 I would appreciate a PR for discussion on https://github.com/litehelpers/Cordova-sqlite-storage.

brody4hire avatar Dec 19 '17 16:12 brody4hire

https://github.com/andpor/react-native-sqlite-storage/pull/220

This might be not ideal but should unblock you.

dryganets avatar Dec 19 '17 18:12 dryganets

Ok, I've created a pull request with the signatures to match the SQLiteFactory (which I called SQLitePlugin) and the SQLitePlugin (which I called Database)

I will gladly receive comments from any of you about this as part of the review process.

The pull request is: #221

rodrigoelp avatar Dec 20 '17 00:12 rodrigoelp

@dryganets just noticed you had created an earlier pull request with your own definitions. I guess @andpor will be happy to pick one of the two and discard the other one.

rodrigoelp avatar Dec 20 '17 09:12 rodrigoelp

@types/react-native-sqlite-storage now exists, so I think this can be closed @andpor

jonmountjoy avatar Feb 24 '20 17:02 jonmountjoy

yep @jonmountjoy, I ended up making the PR to the DT, it was faster to merge. Sorry, should have mentioned that in this thread.

dryganets avatar Feb 24 '20 18:02 dryganets