-
Notifications
You must be signed in to change notification settings - Fork 49
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
Start converting js to ts #5
Start converting js to ts #5
Conversation
FWIW, I've been following your full PR and looks like this is a good starting point for the TS conversion. Excited for the full conversion to merge later. |
You should also try to add JSDOC from the existing documentation so that we can have nice autocompletion hints ! Here is an example of what I added on my side : /** Creates a record in the database.
@param thing REQUIRED - The table name or the specific record id to create.
@param data OPTIONAL - The document / record data to insert.
@example // Create a record with a random id
let person = await db.create('person');
// Create a record with a specific id
let record = await db.create('person:tobie', {
name: 'Tobie',
settings: {
active: true,
marketing: true,
},
});
//This function will run the following query in the database
CREATE $thing CONTENT $data;
*/
create(thing: string, data: any): Promise<any> {
[...]
} And an example of how it render in VScode intelliSense : |
@Trystan-SA Great suggestion! Will look into adding it for the |
nice! Just one side note - do you think its necessary to restate the types in the JSDOC? |
Hi everyone, as you might have seen, we are having the same issues in the various JS repositories (surrealdb/surrealdb.deno#5). What do you think of streamlining our efforts into one common base? |
Co-authored-by: michaelprichardson
Added basic typescript config and tried to change as little as possible to get the conversion started. Added types to the arguments and returns in the
Surreal
class. As this is the front-facing class I thought it would be best to start there and it makes the PR small