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

Start converting js to ts #5

Conversation

michaelprichardson
Copy link

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

@AesSedai
Copy link
Contributor

AesSedai commented Sep 6, 2022

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.

@michaelprichardson michaelprichardson mentioned this pull request Sep 12, 2022
@Trystan-SA
Copy link

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 :

Code_K9tb9PS8z2

@michaelprichardson
Copy link
Author

@Trystan-SA Great suggestion! Will look into adding it for the Surreal class too

@oberbeck
Copy link
Contributor

oberbeck commented Sep 16, 2022

nice!

Just one side note - do you think its necessary to restate the types in the JSDOC?

@oberbeck
Copy link
Contributor

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?

@Chooks22 Chooks22 mentioned this pull request Sep 17, 2022
@tobiemh tobiemh closed this in #14 Sep 18, 2022
mathe42 added a commit to mathe42/surrealdb.js that referenced this pull request Sep 19, 2022
Co-authored-by: michaelprichardson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants